From 0a5aea375d6f90c6b036b75fcb3d8fbd7990b316 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Mon, 31 Oct 2016 14:57:33 -0700 Subject: 39795: preserve "cd -" behavior around directory shuffling in _canonical_paths_pwd --- Completion/Unix/Type/_canonical_paths | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Completion') diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths index 6482602ac..4b6b0c05d 100644 --- a/Completion/Unix/Type/_canonical_paths +++ b/Completion/Unix/Type/_canonical_paths @@ -16,11 +16,13 @@ _canonical_paths_pwd() { # Get the canonical directory name by changing to it. integer chaselinks + local oldpwd=$OLDPWD [[ -o chaselinks ]] && (( chaselinks = 1 )) - setopt localoptions nopushdignoredups chaselinks + setopt localoptions nopushdignoredups chaselinks noautopushd if builtin pushd -q -- $1 2>/dev/null; then REPLY=$PWD (( chaselinks )) || unsetopt chaselinks + [[ -n $oldpwd && -d $oldpwd ]] && builtin cd -q $oldpwd # For "cd -" builtin popd -q else REPLY=$1 -- cgit 1.4.1