diff --git a/share/completions/npm.fish b/share/completions/npm.fish index cd91e81fb..0c57814a4 100644 --- a/share/completions/npm.fish +++ b/share/completions/npm.fish @@ -50,14 +50,13 @@ function __fish_complete_npm --description "Complete the commandline using npm's set -lx COMP_LINE (commandline -o) # COMP_CWORD is the index of the current word in COMP_LINE # bash starts arrays with 0, so subtract 1 - set -l x (count $COMP_LINE) - set -lx COMP_CWORD (math x - 1) + set -lx COMP_CWORD (math (count $COMP_LINE) - 1) # COMP_POINT is the index of point/cursor when the commandline is viewed as a string set -lx COMP_POINT (commandline -C) # If the cursor is after the last word, the empty token will disappear in the expansion # Readd it if test (commandline -ct) = "" - set COMP_CWORD (math COMP_CWORD + 1) + set COMP_CWORD (math $COMP_CWORD + 1) set COMP_LINE $COMP_LINE "" end command npm completion -- $COMP_LINE ^/dev/null diff --git a/share/completions/pushd.fish b/share/completions/pushd.fish index 5a819021a..d38dc298c 100644 --- a/share/completions/pushd.fish +++ b/share/completions/pushd.fish @@ -12,7 +12,7 @@ function __fish_complete_pushd_minus # print each member of the stack, replace $HOME with ~ # Negative arguments are expected to start at "-0" for i in (seq (count $dirstack) -1 1) - printf "%s\t%s\n" -(math i - 1) "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[(math -i)]) + printf "%s\t%s\n" -(math $i - 1) "Rotate to "(string replace -r "^$HOME" "~" -- $dirstack[(math -$i)]) end end end diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index 0a6f39abe..9f5ac1d59 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-shadowin for i in $cmd if test $skip_next -gt 0 - set skip_next (math 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-shadowin else if contains -- $i $argv - set skip_next (math 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 5d99e9ec2..7a964ba99 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 (math shape - 1) + set shape (math $shape - 1) end echo -en "\e[$shape q" end diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 65a27b9d5..f6da6f982 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -488,9 +488,8 @@ function __fish_git_prompt_informative_status set -l info - # If `math` fails for some reason, assume the state is clean - it's the simpler path. - # TBD: Can this be simplified? It should be impossible for the math command to fail here. - set -l state (math dirtystate + invalidstate + stagedstate + untrackedfiles) + # If `math` fails for some reason, assume the state is clean - it's the simpler path + set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles ^/dev/null) if test -z "$state" or test "$state" = 0 set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish index 498eba170..5c9604a7b 100644 --- a/share/functions/__fish_print_help.fish +++ b/share/functions/__fish_print_help.fish @@ -34,7 +34,7 @@ function __fish_print_help --description "Print help message for the specified f end 3<&1 end if test -n "$cols" - set cols (math 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 -lx GROFF_TMAC_PATH $__fish_datadir/groff diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 514b4e505..6809039fb 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -40,9 +40,7 @@ function __fish_print_packages set cache_file $XDG_CACHE_HOME/.pac-cache.$USER if test -f $cache_file cat $cache_file - set -l x (date +%s) - set -l y (stat -c '%Y' $cache_file) - set age (math x - y) + set age (math (date +%s) - (stat -c '%Y' $cache_file)) set max_age 250 if test $age -lt $max_age return @@ -67,9 +65,7 @@ function __fish_print_packages set -l cache_file $XDG_CACHE_HOME/.zypper-cache.$USER if test -f $cache_file cat $cache_file - set -l x (date +%s) - set -l y (stat -c '%Y' $cache_file) - set -l age (math x - y) + set -l age (math (date +%s) - (stat -c '%Y' $cache_file)) set -l max_age 300 if test $age -lt $max_age return @@ -89,9 +85,7 @@ function __fish_print_packages set cache_file $XDG_CACHE_HOME/.yum-cache.$USER if test -f $cache_file cat $cache_file - set -l x (date +%s) - set -l y (stat -c '%Y' $cache_file) - set age (math x - y) + set age (math (date +%s) - (stat -c '%Y' $cache_file)) set max_age 21600 if test $age -lt $max_age return @@ -113,9 +107,7 @@ function __fish_print_packages set cache_file $XDG_CACHE_HOME/.rpm-cache.$USER if test -f $cache_file cat $cache_file - set -l x (date +%s) - set -l y (stat -c '%Y' $cache_file) - set age (math x - y) + set age (math (date +%s) - (stat -c '%Y' $cache_file)) set max_age 250 if test $age -lt $max_age return diff --git a/share/functions/__fish_svn_prompt.fish b/share/functions/__fish_svn_prompt.fish index 46161d88e..5c649c2cd 100644 --- a/share/functions/__fish_svn_prompt.fish +++ b/share/functions/__fish_svn_prompt.fish @@ -132,7 +132,7 @@ function __fish_svn_prompt --description "Prompt function for svn" # the default separator is empty set -l prompt_separator "" - for index in (seq (math col - last_column)) + for index in (seq (math "$col - $last_column")) # the prompt separator variable has to be updated with the number of separators needed to represent empty status columns (eg: if a file has the status "A +" then it should display as "A|||+" in the prompt) set prompt_separator $prompt_separator$__fish_svn_prompt_char_separator end diff --git a/share/functions/contains_seq.fish b/share/functions/contains_seq.fish index d99dd9603..d3a20e1c8 100644 --- a/share/functions/contains_seq.fish +++ b/share/functions/contains_seq.fish @@ -23,7 +23,7 @@ function contains_seq --description 'Return true if array contains a sequence' end if test "$s" = "$pattern[$i]" set -e nomatch[1] - set i (math i + 1) + set i (math $i + 1) if not set -q pattern[$i] if set -q printnext[1] set printnext[2] 1 diff --git a/share/functions/fish_breakpoint_prompt.fish b/share/functions/fish_breakpoint_prompt.fish index 950658b39..24d27d6d9 100644 --- a/share/functions/fish_breakpoint_prompt.fish +++ b/share/functions/fish_breakpoint_prompt.fish @@ -14,9 +14,9 @@ function fish_breakpoint_prompt --description "A right prompt to be used when `b set prompt "$prompt > " # Make sure the prompt doesn't consume more than half the terminal width. - set -l max_len (math COLUMNS / 2) + set -l max_len (math "$COLUMNS / 2") if test (string length -- $prompt) -gt $max_len - set prompt ...(string sub -s -(math max_len - 3) -- $prompt) + set prompt ...(string sub -s -(math $max_len - 3) -- $prompt) end echo -ns (set_color $fish_color_status) "BP $prompt" (set_color normal) ' ' diff --git a/share/functions/pushd.fish b/share/functions/pushd.fish index e90e55de1..52af5c466 100644 --- a/share/functions/pushd.fish +++ b/share/functions/pushd.fish @@ -53,8 +53,7 @@ function pushd --description 'Push directory to stack' return 1 end - set -l x (count $stack) - set rot_l (math x - 1 - rot_r) + set rot_l (math (count $stack) - 1 - $rot_r) end # check the rotation in range @@ -64,7 +63,7 @@ function pushd --description 'Push directory to stack' else # rotate stack unless rot_l is 0 if test $rot_l -gt 0 - set stack $stack[(math rot_l + 1)..(count $stack)] $stack[1..$rot_l] + set stack $stack[(math $rot_l + 1)..(count $stack)] $stack[1..$rot_l] end # now reconstruct dirstack and change directory diff --git a/share/functions/umask.fish b/share/functions/umask.fish index 1249d308b..d6147d680 100644 --- a/share/functions/umask.fish +++ b/share/functions/umask.fish @@ -98,10 +98,10 @@ function __fish_umask_parse set val 4 end if string match -q '*w*' $perms - set val (math val + 2) + set val (math $val + 2) end if string match -q '*x*' $perms - set val (math val + 1) + set val (math $val + 1) end for j in $scopes_to_modify