mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 11:45:08 +00:00
more changes to better handle undef vars
This is only needed if we make undefined vars an error as proposed in issue #4163 but it's a good idea anyway.
This commit is contained in:
parent
4f345fdee7
commit
763063e741
4 changed files with 13 additions and 6 deletions
|
@ -31,6 +31,8 @@ function cd --description "Change directory"
|
||||||
set -l cd_status $status
|
set -l cd_status $status
|
||||||
|
|
||||||
if test $cd_status -eq 0 -a "$PWD" != "$previous"
|
if test $cd_status -eq 0 -a "$PWD" != "$previous"
|
||||||
|
set -q dirprev
|
||||||
|
or set -l dirprev
|
||||||
set -q dirprev[$MAX_DIR_HIST]
|
set -q dirprev[$MAX_DIR_HIST]
|
||||||
and set -e dirprev[1]
|
and set -e dirprev[1]
|
||||||
set -g dirprev $dirprev $previous
|
set -g dirprev $dirprev $previous
|
||||||
|
|
|
@ -8,12 +8,11 @@ function popd --description "Pop directory from the stack and cd to it"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if test $dirstack[1]
|
if set -q dirstack[1]
|
||||||
cd $dirstack[1]
|
cd $dirstack[1]
|
||||||
|
set -e dirstack[1]
|
||||||
else
|
else
|
||||||
printf (_ "%s: Directory stack is empty…\n") popd 1>&2
|
printf (_ "%s: Directory stack is empty…\n") popd 1>&2
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
set -e dirstack[1]
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,10 +18,13 @@ function pushd --description 'Push directory to stack'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -q dirstack
|
||||||
|
or set -g dirstack
|
||||||
|
|
||||||
# emulate bash: an empty pushd should switch the top of dirs
|
# emulate bash: an empty pushd should switch the top of dirs
|
||||||
if test (count $argv) -eq 0
|
if not set -q argv[1]
|
||||||
# check that the stack isn't empty
|
# check that the stack isn't empty
|
||||||
if test (count $dirstack) -eq 0
|
if not set -q dirstack[1]
|
||||||
echo "pushd: no other directory"
|
echo "pushd: no other directory"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,10 @@ end
|
||||||
set TERM xterm
|
set TERM xterm
|
||||||
set -e ITERM_PROFILE
|
set -e ITERM_PROFILE
|
||||||
|
|
||||||
source test_util.fish (status -f) $argv; or exit
|
set -q argv
|
||||||
|
or set argv
|
||||||
|
source test_util.fish (status -f) $argv
|
||||||
|
or exit
|
||||||
|
|
||||||
say -o cyan "Testing high level script functionality"
|
say -o cyan "Testing high level script functionality"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue