aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2016-02-03 23:23:59 +0100
committerGravatar Fabian Homborg <FHomborg@gmail.com>2016-02-03 23:23:59 +0100
commit158ea98189f6c5c410ea8b58f466a5ef6a8f1a33 (patch)
tree706beb417907de7154c2d6783aaed3519c6d10a0 /share/functions
parent962f9914c61f6ab0e744009cafa56d072bbfc8a6 (diff)
Replace uses of expr with math/string
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/__fish_complete_subcommand.fish4
-rw-r--r--share/functions/__fish_cursor_xterm.fish2
-rw-r--r--share/functions/__fish_is_token_n.fish11
-rw-r--r--share/functions/__fish_print_help.fish2
-rw-r--r--share/functions/contains_seq.fish6
5 files changed, 8 insertions, 17 deletions
diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish
index 203deb05..244d1a23 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 a82be021..c7dd1690 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 d2129e26..c6069bde 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 02bc499a..3d5ac0b6 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 917415b9..9fae7cac 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