#!/bin/rc # watch # -c: don't clear between updates # -e: exit on command error # -t: don't show title date and time # -m: set maximum number of lines to show # -n: set interval in seconds (may be floating point) rfork e flagfmt='c,e,t,m maxlines,n interval' args='cmd [arg ...]' fn usage{ aux/usage exit usage } fn isfloat{ echo $1 | grep -s '^[0-9\.]+$' } fn isnum{ echo $1 | grep -s '^[0-9]+$' } fn clear{ awk 'END { for(i = 0; i < '$len'; i++) printf "\x08" }' [2=1]} stat=$status ifs=$oifs if(~ $#flagc 0 && ~ $#len 1) clear len=`{output | wc -r} output if(~ $flage 1 && ! ~ $stat ''){ echo status'='$"stat exit $"stat } sleep $int }