mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 11:45:08 +00:00
Replace uses of expr with math/string
This commit is contained in:
parent
962f9914c6
commit
158ea98189
6 changed files with 9 additions and 18 deletions
|
@ -20,4 +20,4 @@ complete -c cower -f -s v -l 'verbose' -d 'Output more'
|
||||||
|
|
||||||
# Complete with AUR packages:
|
# Complete with AUR packages:
|
||||||
# If the search string is too short, cower prints an annoying message to stderr - ignore that
|
# If the search string is too short, cower prints an annoying message to stderr - ignore that
|
||||||
complete -c cower -f -n 'not expr -- (commandline --current-token) : "^\-.*" > /dev/null' -a '(cower --format="%n\t%d\n" --search (commandline --current-token) ^/dev/null)'
|
complete -c cower -f -n 'not string match -q -- "-*" (commandline --current-token)' -a '(cower --format="%n\t%d\n" --search (commandline --current-token) ^/dev/null)'
|
||||||
|
|
|
@ -15,7 +15,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowi
|
||||||
for i in $cmd
|
for i in $cmd
|
||||||
|
|
||||||
if test $skip_next -gt 0
|
if test $skip_next -gt 0
|
||||||
set skip_next (expr $skip_next - 1)
|
set skip_next (math $skip_next - 1)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowi
|
||||||
else
|
else
|
||||||
|
|
||||||
if contains -- $i $argv
|
if contains -- $i $argv
|
||||||
set skip_next (expr $skip_next + 1)
|
set skip_next (math $skip_next + 1)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)'
|
||||||
set shape 6
|
set shape 6
|
||||||
end
|
end
|
||||||
if contains blink $argv
|
if contains blink $argv
|
||||||
set shape (expr $shape - 1)
|
set shape (math $shape - 1)
|
||||||
end
|
end
|
||||||
echo -en "\e[$shape q"
|
echo -en "\e[$shape q"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
function __fish_is_token_n --description 'Test if current token is on Nth place' --argument n
|
function __fish_is_token_n --description 'Test if current token is on Nth place' --argument n
|
||||||
set -l num (count (commandline -poc))
|
# Add a fake element to increment without calling math
|
||||||
#if test $cur
|
set -l num (count (commandline -poc) additionalelement)
|
||||||
expr $n = $num + 1 > /dev/null
|
test $n -eq $num
|
||||||
#else
|
|
||||||
#expr $n '=' $num + 1 > /dev/null
|
|
||||||
#end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
end 3<&1
|
end 3<&1
|
||||||
end
|
end
|
||||||
if test -n "$cols"
|
if test -n "$cols"
|
||||||
set cols (expr $cols - 4) # leave a bit of space on the right
|
set cols (math $cols - 4) # leave a bit of space on the right
|
||||||
set rLL -rLL=$cols[1]n
|
set rLL -rLL=$cols[1]n
|
||||||
end
|
end
|
||||||
set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
||||||
|
|
|
@ -19,15 +19,11 @@ function contains_seq --description 'Return true if array contains a sequence'
|
||||||
set -l i 1
|
set -l i 1
|
||||||
for s in $string
|
for s in $string
|
||||||
if set -q printnext[2]
|
if set -q printnext[2]
|
||||||
#echo $s
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
#echo a $nomatch
|
|
||||||
if test "$s" = "$pattern[$i]"
|
if test "$s" = "$pattern[$i]"
|
||||||
#echo b $nomatch
|
|
||||||
#echo c $nomatch[1]
|
|
||||||
set -e nomatch[1]
|
set -e nomatch[1]
|
||||||
set i (expr $i + 1)
|
set i (math $i + 1)
|
||||||
if not set -q pattern[$i]
|
if not set -q pattern[$i]
|
||||||
if set -q printnext[1]
|
if set -q printnext[1]
|
||||||
set printnext[2] 1
|
set printnext[2] 1
|
||||||
|
|
Loading…
Reference in a new issue