GNU bug report logs -
#13525
8.20 - [seq 1 3 1] treated as [seq 1 3]
Previous Next
Reported by: "Marcel Böhme" <hawkie <at> web.de>
Date: Tue, 22 Jan 2013 10:45:02 UTC
Severity: normal
Found in version 8.20
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 01/22/2013 02:24 PM, Pádraig Brady wrote:
> 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.
Yes, from a mathematical point of view, seq is right.
Therefore, maybe documenting seq's behavior would suffice.
OTOH ...
> Maybe we should special case to only print
> the start value once if step = 0.
... users may not be amused about an endless loop in a tool
which is otherwise meant for counting, e.g.
$ seq $start $step $last | \
while read x ; do work_on $s ; done
Stopping after the start valie is maybe not mathematically
correct, but more "natural".
> 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; }
TBH this doesn't look like as if a normal user would be
able to invent this. ;-)
Have a nice day,
Berny
This bug report was last modified 12 years and 179 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.