about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 15:33:44 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 15:33:44 +0200
commit6bf5b7f2c5b1d6d1fe52fc17d21f0b4d63eb367b (patch)
tree73c3d43c7ec64e6129706b6d44bd29f9ce03cfba
parente8c199871d2a7f5a7668f9a9759b63a3cbee662d (diff)
downloadnq-6bf5b7f2c5b1d6d1fe52fc17d21f0b4d63eb367b.tar.gz
nq-6bf5b7f2c5b1d6d1fe52fc17d21f0b4d63eb367b.tar.xz
nq-6bf5b7f2c5b1d6d1fe52fc17d21f0b4d63eb367b.zip
fq: output last job when all ran already
-rw-r--r--README.md3
-rwxr-xr-xfq8
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