On 01/22/2013 12:28 PM, Bernhard Voelker wrote:
On 01/22/2013 01:17 PM, Pádraig Brady wrote:
Updated patch attached.
That one is looking good ... but while we're at it:
Anyone tried this, i.e. a Zero as INCREMENT?
$ seq 1 0 2
This is equal to `yes 0`. Well, this is probably a (not
documented) feature, but in the following examples, the "1"
should be printed only once, shouldn't it?
$ seq 1 0 1
$ seq 1 0.0 1
(BTW: "seq 2 0 1" works, i.e. doesn't print anything.)
Yes I was wondering that myself.
Though I suppose that `seq 0 0 1` prints endlessly,
means that it's consistent that as long as start <= end
and step == 0, then start is printed endlessly.
Maybe we should special case to only print
the start value once if step = 0.
Maybe one could use a step of 0 to hack a
min/max function or something?
min() { minv=$(seq "$1" 0 "$2"); : ${minv:="$2"}; echo $minv; }
max() { minv=$(seq "$1" 0 "$2"); : ${maxv:="$1"}; echo $maxv; }
Though I'm stretching here as that could be done
(albeit with 3 processes) like:
min() { printf '%s\n' "$@" | sort -rg | tail -n1; }
max() { printf '%s\n' "$@" | sort -g | tail -n1; }
cheers,
Pádraig.