dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b2ed076b263fbfcefc873386a08fa2d30f95ad56
parent 4fc1320ced9ec0c303ff69fed8466acd502bccd1
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu,  2 May 2019 16:16:24 +0200

Add tsp-rerun script

Diffstat:
Abin/tsp-rerun | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+), 0 deletions(-)

diff --git a/bin/tsp-rerun b/bin/tsp-rerun @@ -0,0 +1,73 @@ +#!/bin/sh + +version=0.1 + +show_help() { + echo "usage: ${0##*/} [OPTIONS] ID1 [ID2...[ID N]]" + echo "will rerun the command from each job ID from 'tsp' as a new 'tsp' job" + echo "If no ID is specified, this program will expect IDs as stdin." + echo + echo "OPTIONS are one or more of the following:" + echo " -V, --verbose show diagnostic information during execution" + echo " -v, --version show version and license information" + echo " -h, --help show this message" + echo " -- do not consider any following args as options" +} + +show_version() { + echo "${0##*/} version $version" + echo "Licensed under the GNU Public License, v3+" + echo "written by Anders Damsgaard, anders@adamsgaard.dk" + echo "https://gitlab.com/admesg/dotfiles" +} + +get_tsp_job_command() { + tsp | grep "^$1 " | sed 's/ */ /g' | cut -d' ' -f6- +} + +handle_id() { + cmd="tsp $(get_tsp_job_command "$1")" + [ "$verbose" = 1 ] && echo "$cmd" + eval "$cmd" +} + +die() { + printf '%s\n' "$1" >&2 + exit 1 +} + +verbose=0 +while :; do + case "$1" in + -h|-\?|--help) + show_help + exit 0 + ;; + -v|--version) + show_version + exit 0 + ;; + -V|--verbose) + verbose=1 + ;; + --) # end all options + shift + break + ;; + -?*) + die 'Error: Unknown option specified' + ;; + *) # No more options + break + esac + shift +done + +if [ $# -lt 1 ]; then + id="$(cat)" + handle_id "$id" +else + for id in "$@"; do + handle_id "$id" + done +fi