Add RR: run command until failure

This commit is contained in:
Adolfo Perez Alvarez 2022-06-10 09:51:20 +02:00
parent 710062d6e1
commit 7c59191590
3 changed files with 47 additions and 1 deletions

View File

@ -1,7 +1,7 @@
prefix=$$HOME/opt/pkg/miscutils
target_bin=${prefix}/bin
target_man=${prefix}/share/man/man1
bin=bwrap hppt mkgmap newp rot scmfmt upcasetl unpage
bin=bwrap hppt mkgmap newp rot rr scmfmt upcasetl unpage
install:
install -d ${target_bin} ${target_man}
install -c ${bin} ${target_bin}

16
rr Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
[ $# -eq 1 ] && echo "usage: $0 command ..." && exit 64
tmp1=$(mktemp $0.XXXXXXXXXX)
tmp2=$(mktemp $0.XXXXXXXXXX)
trap "rm $tmp1 $tmp2; exit 0" 1 2 15
while "$@" >$tmp2
do
if ! diff $tmp1 $tmp2
then
cp $tmp2 $tmp1
else
echo -n "."
fi
sleep 2
done
rm $tmp1 $tmp2

30
rr.1 Normal file
View File

@ -0,0 +1,30 @@
.Dd Jun 10, 2022
.Dt RR 1
.Os
.Sh NAME
.Nm rr
.Nd Repeteadly run a command until it exits with a non zero status
.Sh SYNOPSIS
.Nm
.Ar cmd Op Ar arg ...
.Sh DESCRIPTION
Run command
.Ar cmd arg ...
repeteadly until it fails.
.Pp
In every run, compare its stdout with the one from the previous run.
If there has been any change, print a diff;
otherwise, display a dot to indicate progress.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
.Bd -literal -offset indent
$ rr pgrep -f foo
0a1,2
> 6871
> 25428
\&...^C
$
.Ed
.Sh AUTHORS
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org