From 7c59191590509b826022c424b5c15d765dd297d1 Mon Sep 17 00:00:00 2001 From: Adolfo Perez Alvarez Date: Fri, 10 Jun 2022 09:51:20 +0200 Subject: [PATCH] Add RR: run command until failure --- Makefile | 2 +- rr | 16 ++++++++++++++++ rr.1 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 rr create mode 100644 rr.1 diff --git a/Makefile b/Makefile index ca8525b..5ca3d2a 100644 --- a/Makefile +++ b/Makefile @@ -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} diff --git a/rr b/rr new file mode 100755 index 0000000..008b0bf --- /dev/null +++ b/rr @@ -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 diff --git a/rr.1 b/rr.1 new file mode 100644 index 0000000..3a3594b --- /dev/null +++ b/rr.1 @@ -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