fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
d835c5252
master
1# localization: skip(uses-apropos) 2 3# If seq is not installed, then define a function that invokes __fish_fallback_seq 4# We can't call type here because that also calls seq 5 6if command -sq seq 7exit 8end 9 10if command -sq gseq 11# No seq provided by the OS, but GNU coreutils was apparently installed, fantastic 12function seq 13gseq $argv 14end 15exit 16end 17 18# No seq command 19function seq 20__fish_fallback_seq $argv 21end 22 23function __fish_fallback_seq 24set -l from1 25set -l step1 26set -l to1 27 28# Remove a "--" argument if it happens first. 29if test "x $argv [ 1 ] " = x-- 30set -e argv[ 1 ] 31end 32 33switch ( count $argv ) 34case 1 35set to$argv [ 1 ] 36case 2 37set from$argv [ 1 ] 38set to$argv [ 2 ] 39case 3 40set from$argv [ 1 ] 41set step$argv [ 2 ] 42set to$argv [ 3 ] 43case '*' 44printf "seq: Expected 1, 2 or 3 arguments, got %d\n" ( count $argv ) >&2 45return 1 46end 47 48for iin $from $step $to 49if not string match -rq --'^-?[0-9]*([0-9]*|\.[0-9]+)$' $i 50printf "seq: '%s' is not a number\n" $i >&2 51return 1 52end 53end 54 55if test $step -ge 0 56set -l i$from 57while test $i -le $to 58echo $i 59set i( math --$i +$step ) 60end 61else 62set -l i$from 63while test $i -ge $to 64echo $i 65set i( math --$i +$step ) 66end 67end 68end