mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 08:41:13 +08:00
Revert "Switch to bare vars in our math
invocations"
This reverts commit bd18736ee5
.
Bare variables should only be used in commands that must
manipulate the variable stack, such as `set`.
This commit is contained in:
parent
c2a5e7ae27
commit
a5fd0b317e
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) ' '
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user