Invoke cd in subshell

This commit is contained in:
Ajeet D'Souza 2020-12-18 07:38:29 +05:30
parent 85f230bd8f
commit 3c76c63b5b
3 changed files with 5 additions and 3 deletions

View File

@ -75,7 +75,7 @@ function __zoxide_z() {
echo 'zoxide: $OLDPWD is not set'
return 1
fi
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
elif [ "$#" -eq 1 ] && (cd "$1" &>{{ Opts::DEVNULL }}); then
__zoxide_cd "$1"
else
local __zoxide_result

View File

@ -79,7 +79,7 @@ __zoxide_z() {
echo 'zoxide: $OLDPWD is not set'
return 1
fi
elif [ "$#" -eq 1 ] && [ -d "$1" ]; then
elif [ "$#" -eq 1 ] && (cd "$1" >{{ Opts::DEVNULL }}) 2>&1; then
__zoxide_cd "$1"
else
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "${__zoxide_result}"

View File

@ -59,7 +59,9 @@ function __zoxide_z() {
echo "zoxide: \\$OLDPWD is not set"
return 1
fi
elif ! { [ "$#" -eq 1 ] && __zoxide_cd "$1" &>{{ Opts::DEVNULL }}; }; then
elif [ "$#" -eq 1 ] && (cd "$1" &>{{ Opts::DEVNULL }}) then
__zoxide_cd "$1"
else
local __zoxide_result
__zoxide_result="$(zoxide query -- "$@")" && __zoxide_cd "$__zoxide_result"
fi