8 partial - Show an earlier started long-running command's partial output
12 partial [--restart|--forget|--wait|--pid] <B<COMMAND>> [<B<ARGUMENTS>>]
16 On first invocation partial(1) starts B<COMMAND> in the background.
17 On subsequent invocations, it prints the command's output to stdout which is
18 generated so far, including the parts which are shown before too,
19 and keep it running in the background.
20 Hence the name 'partial', because it shows a command's partial output.
21 When the command finished, partial(1) prints the whole output
22 and exits with B<COMMAND>'s exit code.
30 Terminate (SIGTERM) previous instance of the same command
31 and clean up status directory, even if it's running.
35 Terminate command if running (like with --forget) and start it again.
39 On first run, wait for the complete output.
65 called command returned with this status code I<nnn>
71 If B<COMMAND> does not exit normally, but gets terminated by a signal,
72 the exit code is indistinguishable from a normal exit's status code,
73 due to bash(1) uses the value of 128+B<N> as the exit status
74 when a command terminates on a fatal signal B<N>.
92 echo "${0##*/}: $*" >&2
97 if [ $opt_quiet = no
]
110 [ ! -e "$1" ] ||
command remove
"$1"
147 warnx
"unknown option: $1"
163 declare -a command=("$@")
164 command_str
=${command[*]}
165 commandhash
=`echo "$command_str" | sha256sum | cut -f1 -d' '`
167 dir
=~
/.cache
/partial
/$commandhash
169 if [ $opt_pid = yes ]
175 if [ $opt_forget = yes ]
179 pid
=`cat "$dir/pid" 2>/dev/null || true`
191 remove
"$dir/running.lock"
193 remove
"$dir/command.txt"
197 if [ $opt_restart = no
]
205 exec {lockfd
}>>"$dir/lock"
208 exec {runlockfd
}>>"$dir/running.lock"
209 verbose warnx
"state in $dir"
211 if flock
-n -x $runlockfd
213 if [ -e "$dir/status" ]
215 verbose warnx
"command finished: $(stat -c %y "$dir/status
")"
217 status
=`cat "$dir/status"`
220 echo "$command_str" > "$dir/command.txt"
222 if [ $opt_wait = yes ]
225 command "${command[@]}" |
tee "$dir/stdout"
226 status
=${PIPESTATUS[0]}
227 echo -n $status >"$dir/status"
234 command "${command[@]}" > "$dir/stdout"
235 echo -n $?
>"$dir/status"
239 verbose warnx
"command started"
247 verbose warnx
"command is in progress since $(stat -c %y "$dir/command.txt
"), partial output follows."