summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-10-31 14:57:33 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-10-31 14:57:33 -0700
commit0a5aea375d6f90c6b036b75fcb3d8fbd7990b316 (patch)
tree2f94ad2dc91afa5d461edc0b7e15172ff696a731
parent59dbab4f1c0898f9a354d85051b1d5a5e776d984 (diff)
downloadzsh-0a5aea375d6f90c6b036b75fcb3d8fbd7990b316.tar.gz
zsh-0a5aea375d6f90c6b036b75fcb3d8fbd7990b316.zip
39795: preserve "cd -" behavior around directory shuffling in _canonical_paths_pwd
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Unix/Type/_canonical_paths4
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2676d0a17..c7b0b8d16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2016-10-31 Barton E. Schaefer <schaefer@zsh.org>
+ * 39795: Completion/Unix/Type/_canonical_paths: preserve "cd -"
+ behavior around directory shuffling in _canonical_paths_pwd
+
* 39792: Completion/Unix/Type/_canonical_paths: improve handling
of relative paths in _canonical_paths_add_paths
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