functions/seq: Fix negative numbers

25d83ed0d7 (included in 3.0.0) added a `string` check that
did not use `--`, so negative numbers were interpreted as options.

Apparently nobody is using this.

(Again, this is for the `seq` fallback used on OpenBSD)
This commit is contained in:
Fabian Homborg 2019-03-07 14:06:06 +01:00
parent e35a30de0a
commit bd5232e0e2

View File

@ -33,7 +33,7 @@ if not command -sq seq
end
for i in $from $step $to
if not string match -rq '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i
if not string match -rq -- '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i
printf (_ "%s: '%s' is not a number\n") seq $i
return 1
end
@ -43,13 +43,13 @@ if not command -sq seq
set -l i $from
while test $i -le $to
echo $i
set i (math $i + $step)
set i (math -- $i + $step)
end
else
set -l i $from
while test $i -ge $to
echo $i
set i (math $i + $step)
set i (math -- $i + $step)
end
end
end