|
From: | Pádraig Brady |
Subject: | bug#13525: 8.20 - [seq 1 3 1] treated as [seq 1 3] |
Date: | Tue, 22 Jan 2013 13:24:30 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
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.
[Prev in Thread] | Current Thread | [Next in Thread] |