From 6bf5b7f2c5b1d6d1fe52fc17d21f0b4d63eb367b Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 3 Aug 2015 15:33:44 +0200 Subject: fq: output last job when all ran already --- README.md | 3 ++- fq | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cc7fe58..f31ab40 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,8 @@ Two helper scripts are provided: `tmux` and GNU `tail`). `fq` outputs the log of the currently running jobs, exiting when the -jobs are done. +jobs are done. If no job is running, the output of the last job is +shown. (A pure shell implementation of `nq` is provided as `nq.sh`. It needs `flock` from util-linux, and only has a timer resolution of 1s. diff --git a/fq b/fq index 8cf3832..99774fe 100755 --- a/fq +++ b/fq @@ -1,11 +1,17 @@ #!/bin/sh -# fq - tail -f the queue outputs, quitting when the job finishes +# fq - tail -F the queue outputs, quitting when the job finishes +tailed=false for f in ${NQDIR:-.}/,*; do if ! nq -t $f; then + tailed=true printf '==> %s\n' "$f" tail -F $f & p=$! nq -w $f kill $p fi done + +if ! $tailed; then + cat $f +fi -- cgit 1.4.1