mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 18:22:45 +08:00
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:
parent
e35a30de0a
commit
bd5232e0e2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user