mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 13:08:49 +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
|
||||
|
||||
if test $cd_status -eq 0 -a "$PWD" != "$previous"
|
||||
set -q dirprev
|
||||
or set -l dirprev
|
||||
set -q dirprev[$MAX_DIR_HIST]
|
||||
and set -e dirprev[1]
|
||||
set -g dirprev $dirprev $previous
|
||||
|
|
|
@ -8,12 +8,11 @@ function popd --description "Pop directory from the stack and cd to it"
|
|||
end
|
||||
end
|
||||
|
||||
if test $dirstack[1]
|
||||
if set -q dirstack[1]
|
||||
cd $dirstack[1]
|
||||
set -e dirstack[1]
|
||||
else
|
||||
printf (_ "%s: Directory stack is empty…\n") popd 1>&2
|
||||
return 1
|
||||
end
|
||||
|
||||
set -e dirstack[1]
|
||||
end
|
||||
|
|
|
@ -18,10 +18,13 @@ function pushd --description 'Push directory to stack'
|
|||
end
|
||||
end
|
||||
|
||||
set -q dirstack
|
||||
or set -g dirstack
|
||||
|
||||
# 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
|
||||
if test (count $dirstack) -eq 0
|
||||
if not set -q dirstack[1]
|
||||
echo "pushd: no other directory"
|
||||
return 1
|
||||
end
|
||||
|
|
|
@ -24,7 +24,10 @@ end
|
|||
set TERM xterm
|
||||
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"
|
||||
|
||||
|
|
Loading…
Reference in a new issue