1 # Generate a sequence from m to n, m defaults to 1.
5 declare -i lo hi i # makes local
6 local _SEQ INIT COMPARE STEP
9 -r) INIT='i=$hi _SEQ=""' COMPARE='let "i >= $lo"' STEP='let i-=1' ; shift ;;
10 *) INIT='i=$lo _SEQ=""' COMPARE='let "i <= $hi"' STEP='let i+=1' ;;
16 *) echo seq: usage: seq [-r] [low] high 1>&2 ; return 2 ;;
19 # equivalent to the as-yet-unimplemented
20 # for (( "$INIT" ; "$COMPARE" ; "$STEP" )); do _SEQ="${_SEQ}$i "; done
22 while eval "$COMPARE"; do
30 # like the APL `iota' function (or at least how I remember it :-)
34 1) seq 1 "$1"; return $?;;
35 *) echo "iota: usage: iota high" 1>&2; return 2;;