On 04/23/2016 07:49 PM, ra...@openmailbox.org wrote:
execline works on a different concept than regular shells:
http://skarnet.org/software/execline/grammar.html

Execline looks interesting, but I don't quite comprehend it. How would a script such as the following be written in execline?

#!/usr/bin/env rc
# Usage: countdown <minutes> OR countdown -s <seconds>

start=`{date +%s}
switch ($1) {  # set $delay to the countdown time in seconds
    case -s; delay=$2
    case *;  delay=`{expr $1 '*' 60}
}
stop=`{expr $start + $delay}
printf 'Starting at ' ; date -d@$start
printf 'Stopping at ' ; date -d@$stop
current=`{date +%s}
while (test $current -lt $stop) {
    remaining=`{expr $stop - $current}
    printf  \r`{date -d0+$remaining ^ ' sec' +%H:%M:%S}
    set-title `{date -d0+$remaining ^ ' sec' +%H:%M:%S}
    sleep 1
    current=`{date +%s}
}
printf '\a\rDONE!   \a\n'
date
xeyes

Reply via email to