Make miscutils/rr a ksh function

Making this a function available through FPATH allows me to use `rr`
with aliases and funcions defined only for interactive shells.
This commit is contained in:
Adolfo Perez Alvarez 2024-03-09 15:57:32 +01:00
parent 2340af8c9d
commit ea22683e87
1 changed files with 19 additions and 0 deletions

19
rr Executable file
View File

@ -0,0 +1,19 @@
function rr
{
(( $# == 0 )) && print "usage: $0 command ..." && return 64
typeset tmp1=$(mktemp $0.XXXXXXXXXX)
typeset tmp2=$(mktemp $0.XXXXXXXXXX)
trap "rm $tmp1 $tmp2; exit 0" 0 1 2 15
while eval "$@" >$tmp2
do
if ! diff $tmp1 $tmp2
then
cp $tmp2 $tmp1
else
print -n "."
fi
sleep 2
done
print
rm $tmp1 $tmp2
}