diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | NEWS.md | 6 | ||||
-rw-r--r-- | README.md | 26 | ||||
-rw-r--r-- | _nq | 6 | ||||
-rw-r--r-- | nq.1 | 16 | ||||
-rw-r--r-- | nqtail.1 (renamed from fq.1) | 8 | ||||
-rw-r--r-- | nqtail.c (renamed from fq.c) | 4 | ||||
-rwxr-xr-x | nqtail.sh (renamed from fq.sh) | 2 | ||||
-rwxr-xr-x | nqterm (renamed from tq) | 6 | ||||
-rw-r--r-- | nqterm.1 (renamed from tq.1) | 10 | ||||
-rwxr-xr-x | tests | 10 |
12 files changed, 54 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore index 9801fb2..4084f8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *~ -fq nq +nqtail ,*.* diff --git a/Makefile b/Makefile index c24de67..db51654 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -ALL=nq fq tq +ALL=nq nqtail nqterm CFLAGS=-g -Wall -O2 @@ -12,7 +12,7 @@ INSTALL=install all: $(ALL) clean: FRC - rm -f nq fq + rm -f nq nqtail check: FRC all prove -v ./tests diff --git a/NEWS.md b/NEWS.md index 9d68484..af1fa51 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +## 1.0 (2024-07-03) + +* **Incompatible change:** The fq utility has been renamed to nqtail. +* **Incompatible change:** The tq utility has been renamed to nqterm. +* nq: add support for a $NQFAILDIR + ## 0.5 (2022-03-26) * **Notable change:** nq now creates files with permissions 0666 and diff --git a/README.md b/README.md index a420dc7..9aa5d03 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Build targets `clean`, `depends`, `all`, without occupying the terminal: % nq make clean % nq make depends % nq make all - % fq + % nqtail ... look at output, can interrupt with C-c any time without stopping the build ... @@ -70,7 +70,7 @@ Simple download queue, accessible from multiple terminals: % mkdir -p /tmp/downloads % alias qget='NQDIR=/tmp/downloads nq wget' - % alias qwait='NQDIR=/tmp/downloads fq -q' + % alias qwait='NQDIR=/tmp/downloads nqtail -q' window1% qget http://mymirror/big1.iso window2% qget http://mymirror/big2.iso window3% qget http://mymirror/big3.iso @@ -86,8 +86,8 @@ too!): ,14f6f3034f8.17035 remote% ^D % ssh remote - remote% fq - ... see output, fq exits when job finished ... + remote% nqtail + ... see output, nqtail exits when job finished ... ## Assumptions @@ -103,14 +103,16 @@ too!): Two helper programs are provided: -**`fq`** outputs the log of the currently running jobs, exiting when the -jobs are done. If no job is running, the output of the last job is -shown. `fq -a` shows the output of all jobs, `fq -q` only shows one -line per job. `fq` uses `inotify` on Linux and falls back to polling -for size change else. (`fq.sh` is a similar tool, not quite as robust, -implemented as shell-script calling `tail`.) +**`nqtail`** outputs the log of the currently running jobs, exiting +when the jobs are done. If no job is running, the output of the last +job is shown. `nqtail -a` shows the output of all jobs, `nqtail -q` +only shows one line per job. `nqtail` uses `inotify` on Linux and +falls back to polling for size change else. (`nqtail.sh` is a similar +tool, not quite as robust, implemented as shell-script calling +`tail`.) -**`tq`** wraps `nq` and displays the `fq` output in a new `tmux` or screen window. +**`nqterm`** wraps `nq` and displays the `nqtail` output in a new +`tmux` or screen window. (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. @@ -136,7 +138,7 @@ Perl's `prove` installed. Any directory can be a queue for `nq`. `task-spooler` can have different queues for different terminals. -* You can follow the output of an `nq` queue tail-style with `fq`. +* You can follow the output of an `nq` queue tail-style with `nqtail`. * The syntax is different: `at` and `batch` take whole scripts from the standard input or a file; `nq` takes a single command as its diff --git a/_nq b/_nq index 27269b9..a5b86b6 100644 --- a/_nq +++ b/_nq @@ -1,4 +1,4 @@ -#compdef nq tq fq +#compdef nq nqtail nqterm _nq_job() { compadd "$@" -- ${NQDIR:-.}/,*.*(:t) @@ -6,7 +6,7 @@ _nq_job() { _nq() { case "$service" in - fq) _arguments -s -A : \ + nqtail) _arguments -s -A : \ '-q[show only one line per job]' \ '-a[output for all jobs]' \ '*::job:_nq_job' @@ -17,7 +17,7 @@ _nq() { '(-):command name: _command_names -e' \ '*::arguments:_normal' ;; - tq) _arguments : \ + nqterm) _arguments : \ '(-):command name: _command_names -e' \ '*::arguments:_normal' ;; diff --git a/nq.1 b/nq.1 index 921a4b4..8bef666 100644 --- a/nq.1 +++ b/nq.1 @@ -1,4 +1,4 @@ -.Dd March 13, 2021 +.Dd July 3, 2024 .Dt NQ 1 .Os .Sh NAME @@ -47,7 +47,7 @@ and detaches from the terminal immediately, running the job in the background. Standard output and standard error are redirected into the job id file. -.Xr fq 1 +.Xr nqtail 1 can be used to conveniently watch the log files. .Pp The options are as follows: @@ -139,7 +139,7 @@ without occupying the terminal: % nq make clean % nq make depends % nq make all -% fq +% nqtail \&... look at output, can interrupt with C-c any time without stopping the build ... .Ed @@ -147,7 +147,7 @@ without stopping the build ... Simple download queue, accessible from multiple terminals: .Bd -literal -offset indent % alias qget='NQDIR=/tmp/downloads nq wget' -% alias qwait='NQDIR=/tmp/downloads fq -q' +% alias qwait='NQDIR=/tmp/downloads nqtail -q' window1% qget http://mymirror/big1.iso window2% qget http://mymirror/big2.iso window3% qget http://mymirror/big3.iso @@ -167,8 +167,8 @@ remote% nq ./run-benchmark ,14f6f3034f8.17035 remote% ^D % ssh remote -remote% fq -\&... see output, fq exits when job finished ... +remote% nqtail +\&... see output, nqtail exits when job finished ... .Ed .Sh TRICKS The "file extension" of the log file is actually the PID of the job. @@ -238,8 +238,8 @@ into .Pa \&. ) . .El .Sh SEE ALSO -.Xr fq 1 , -.Xr tq 1 . +.Xr nqtail 1 , +.Xr nqterm 1 . .Pp Alternatives to the .Nm diff --git a/fq.1 b/nqtail.1 index dec179b..87273ee 100644 --- a/fq.1 +++ b/nqtail.1 @@ -1,8 +1,8 @@ -.Dd January 31, 2021 -.Dt FQ 1 +.Dd July 3, 2024 +.Dt NQTAIL 1 .Os .Sh NAME -.Nm fq +.Nm nqtail .Nd job queue log viewer .Sh SYNOPSIS .Nm @@ -55,7 +55,7 @@ is used. On other operating systems, polling is used. .Sh SEE ALSO .Xr nq 1 , -.Xr tq 1 +.Xr nqterm 1 .Sh AUTHORS .An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE diff --git a/fq.c b/nqtail.c index a61240f..5dba4b3 100644 --- a/fq.c +++ b/nqtail.c @@ -1,5 +1,5 @@ /* - * fq [FILES...] - follow output of nq jobs, quitting when they are done + * nqtail [FILES...] - follow output of nq jobs, quitting when they are done * * To the extent possible under law, Leah Neukirchen <leah@vuxu.org> * has waived all copyright and related or neighboring rights to this work. @@ -89,7 +89,7 @@ main(int argc, char *argv[]) qflag = 1; break; default: - fputs("usage: fq [-anq] [JOBID...]\n", stderr); + fputs("usage: nqtail [-anq] [JOBID...]\n", stderr); exit(1); } } diff --git a/fq.sh b/nqtail.sh index 99774fe..d2d3816 100755 --- a/fq.sh +++ b/nqtail.sh @@ -1,5 +1,5 @@ #!/bin/sh -# fq - tail -F the queue outputs, quitting when the job finishes +# nqtail - tail -F the queue outputs, quitting when the job finishes tailed=false for f in ${NQDIR:-.}/,*; do diff --git a/tq b/nqterm index b3449c4..06b5741 100755 --- a/tq +++ b/nqterm @@ -1,5 +1,5 @@ #!/bin/sh -# tq CMD... - tmux/screen wrapper for nq to display output in new window +# nqterm CMD... - tmux/screen wrapper for nq to display output in new window set -e @@ -12,12 +12,12 @@ if [ -n "$p" ]; then if [ -n "$TMUX" ]; then tmux new-window -a -d -n '<' -c '#{pane_current_path}' \ "trap true INT QUIT TERM EXIT; - fq $s || kill $p; + nqtail $s || kill $p; printf '[%d exited, ^D to exit.]\n' $p; cat >/dev/null" elif [ -n "$STY" ]; then screen -t '<' sh -c "trap true INT QUIT TERM EXIT; - fq $s || kill $p + nqtail $s || kill $p printf '[%d exited, ^D to exit.]\n' $p; cat >/dev/null" screen -X other diff --git a/tq.1 b/nqterm.1 index b0eaaa1..a217f8f 100644 --- a/tq.1 +++ b/nqterm.1 @@ -1,8 +1,8 @@ -.Dd August 25, 2015 -.Dt TQ 1 +.Dd July 3, 2024 +.Dt NQTERM 1 .Os .Sh NAME -.Nm tq +.Nm nqterm .Nd job queue wrapper for tmux/screen .Sh SYNOPSIS .Nm @@ -12,7 +12,7 @@ is a tiny wrapper around the .Xr nq 1 job queue which automatically spawns a corresponding -.Xr fq 1 +.Xr nqtail 1 watching process in a new .Xr tmux 1 or @@ -37,8 +37,8 @@ Directory where lock files/job output resides, see .Sh EXIT STATUS .Ex -std .Sh SEE ALSO -.Xr fq 1 , .Xr nq 1 , +.Xr nqtail 1 , .Xr screen 1 , .Xr tmux 1 .Sh AUTHORS diff --git a/tests b/tests index 0e664ad..0f4b933 100755 --- a/tests +++ b/tests @@ -1,7 +1,7 @@ #!/bin/sh : ${NQ:=../nq} -: ${FQ:=../fq} +: ${NQTAIL:=../nqtail} set -e @@ -86,19 +86,19 @@ mkdir test.dir ( cd test.dir -printf '# fq tests\n' +printf '# nqtail tests\n' check 'spawning four jobs' 'f1=$($NQ sleep 100)' check 'spawning four jobs' 'f2=$($NQ echo two)' check 'spawning four jobs' 'f3=$($NQ sleep 300)' check 'spawning four jobs' 'f4=$($NQ sleep 400)' -check 'fq tracks first job' '($FQ ,* & p=$!; sleep 1; kill $p) | sed 3q | grep -q sleep.*100' +check 'nqtail tracks first job' '($NQTAIL ,* & p=$!; sleep 1; kill $p) | sed 3q | grep -q sleep.*100' check 'killing first job' kill ${f1##*.} check 'killing fourth job' kill ${f4##*.} sleep 1 -check 'fq tracks third job' '($FQ ,* & p=$!; sleep 1; kill $p) | sed 3q | grep -q sleep.*300' +check 'nqtail tracks third job' '($NQTAIL ,* & p=$!; sleep 1; kill $p) | sed 3q | grep -q sleep.*300' check 'killing third job' kill ${f3##*.} sleep 1 -check 'fq outputs last job when no job running' '$FQ ,* | sed 3q | grep -q sleep.*400' +check 'nqtail outputs last job when no job running' '$NQTAIL ,* | sed 3q | grep -q sleep.*400' ) rm -rf test.dir |