[dev] execline shell

From: Greg Reagle <greg.reagle_AT_umbc.edu>
Date: Sun, 24 Apr 2016 08:58:03 -0400

On 04/23/2016 07:49 PM, rain1_AT_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_AT_$start
printf 'Stopping at ' ; date -d_AT_$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
Received on Sun Apr 24 2016 - 14:58:03 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 24 2016 - 15:00:14 CEST