From 158ea98189f6c5c410ea8b58f466a5ef6a8f1a33 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 3 Feb 2016 23:23:59 +0100 Subject: [PATCH] Replace uses of expr with math/string --- share/completions/cower.fish | 2 +- share/functions/__fish_complete_subcommand.fish | 4 ++-- share/functions/__fish_cursor_xterm.fish | 2 +- share/functions/__fish_is_token_n.fish | 11 +++-------- share/functions/__fish_print_help.fish | 2 +- share/functions/contains_seq.fish | 6 +----- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/share/completions/cower.fish b/share/completions/cower.fish index 743b44455..83918d9cb 100644 --- a/share/completions/cower.fish +++ b/share/completions/cower.fish @@ -20,4 +20,4 @@ complete -c cower -f -s v -l 'verbose' -d 'Output more' # Complete with AUR packages: # 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)' diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index 203deb053..244d1a231 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -15,7 +15,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowi for i in $cmd if test $skip_next -gt 0 - set skip_next (expr $skip_next - 1) + set skip_next (math $skip_next - 1) continue end @@ -24,7 +24,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowi else if contains -- $i $argv - set skip_next (expr $skip_next + 1) + set skip_next (math $skip_next + 1) continue end diff --git a/share/functions/__fish_cursor_xterm.fish b/share/functions/__fish_cursor_xterm.fish index a82be021f..c7dd1690f 100644 --- a/share/functions/__fish_cursor_xterm.fish +++ b/share/functions/__fish_cursor_xterm.fish @@ -10,7 +10,7 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)' set shape 6 end if contains blink $argv - set shape (expr $shape - 1) + set shape (math $shape - 1) end echo -en "\e[$shape q" end diff --git a/share/functions/__fish_is_token_n.fish b/share/functions/__fish_is_token_n.fish index d2129e267..c6069bde1 100644 --- a/share/functions/__fish_is_token_n.fish +++ b/share/functions/__fish_is_token_n.fish @@ -1,10 +1,5 @@ function __fish_is_token_n --description 'Test if current token is on Nth place' --argument n - set -l num (count (commandline -poc)) - #if test $cur - expr $n = $num + 1 > /dev/null - #else - #expr $n '=' $num + 1 > /dev/null - #end - - + # Add a fake element to increment without calling math + set -l num (count (commandline -poc) additionalelement) + test $n -eq $num end diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index 02bc499a3..3d5ac0b6a 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -36,7 +36,7 @@ function __fish_print_help --description "Print help message for the specified f end 3<&1 end 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 end set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null) diff --git a/share/functions/contains_seq.fish b/share/functions/contains_seq.fish index 917415b9b..9fae7cacf 100644 --- a/share/functions/contains_seq.fish +++ b/share/functions/contains_seq.fish @@ -19,15 +19,11 @@ function contains_seq --description 'Return true if array contains a sequence' set -l i 1 for s in $string if set -q printnext[2] - #echo $s return 0 end - #echo a $nomatch if test "$s" = "$pattern[$i]" - #echo b $nomatch - #echo c $nomatch[1] set -e nomatch[1] - set i (expr $i + 1) + set i (math $i + 1) if not set -q pattern[$i] if set -q printnext[1] set printnext[2] 1