summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2013-09-10 08:14:37 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2013-09-10 08:14:37 -0700
commit012668e14ec7305c404975da8c5ba648c1586a82 (patch)
tree3196ae5962b9fe8fcad997b57579a66aeb0dd112
parentcc83fd9916e1c0ea3c13162127e8f61b165974f2 (diff)
downloadzsh-012668e14ec7305c404975da8c5ba648c1586a82.tar.gz
zsh-012668e14ec7305c404975da8c5ba648c1586a82.zip
31714: handle ".." properly when $PWD or the path prefix traverses a symbolic link.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Zsh/Command/_cd16
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 829973181..196b78dd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-09-10 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 31714: Completion/Zsh/Command/_cd: handle ".." properly when
+ $PWD or the path prefix traverses a symbolic link.
+
2013-09-08 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 31711: Doc/Zsh/contrib.yo, Functions/MIME/zsh-mime-handler:
diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
index 476947f60..a5d328fc5 100644
--- a/Completion/Zsh/Command/_cd
+++ b/Completion/Zsh/Command/_cd
@@ -51,6 +51,18 @@ else
_directory_stack && ret=0
fi
+ local -a tmpWpath
+ if [[ $PREFIX = (|*/)../* ]]; then
+ local tmpprefix
+ # Use cd in a subshell to properly [not] resolve symlinks
+ tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD)
+ if [[ -n $tmpprefix ]]; then
+ tmpWpath=(-W $tmpprefix)
+ IPREFIX=${IPREFIX}${PREFIX%/*}/
+ PREFIX=${PREFIX##*/}
+ fi
+ fi
+
if [[ $PREFIX != (\~|/|./|../)* ]]; then
local tmpcdpath alt
@@ -88,7 +100,7 @@ else
# already handled by _command_names (see _autocd)
[[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] &&
- alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files -/" "$alt[@]" )
+ alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" )
if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] &&
zstyle -t ":completion:${curcontext}:options" complete-options; then
@@ -100,7 +112,7 @@ else
return ret
fi
[[ CURRENT -ne 1 ]] && _wanted directories expl directory \
- _path_files -/ && ret=0
+ _path_files $tmpWpath -/ && ret=0
return ret
fi