summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Type/_canonical_paths66
1 files changed, 4 insertions, 62 deletions
diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
index 4b6b0c05d..6eab7b677 100644
--- a/Completion/Unix/Type/_canonical_paths
+++ b/Completion/Unix/Type/_canonical_paths
@@ -7,59 +7,12 @@
 
 # Usage: _canonical_paths [-A var] [-N] [-MJV12nfX] tag desc [paths...]
 
-# -A, if specified, takes the paths from the array variable specified. Paths can
-# also be specified on the command line as shown above. -N, if specified,
+# -A, if specified, takes the paths from the array variable specified. Paths
+# can also be specified on the command line as shown above. -N, if specified,
 # prevents canonicalizing the paths given before using them for completion, in
 # case they are already so. `tag' and `desc' arguments are well, obvious :) In
 # addition, the options -M, -J, -V, -1, -2, -n, -F, -X are passed to compadd.
 
-_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 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
-  fi
-}
-
-_canonical_paths_get_canonical_path() {
-  typeset newfile nondir
-  typeset -A seen
-
-  REPLY=$1
-  # Canonicalise the directory path.  We may not be able to
-  # do this if we can't read all components.
-  if [[ -d $REPLY ]]; then
-    _canonical_paths_pwd $REPLY
-  else
-    # Resolve any trailing symbolic links, guarding against loops.
-    while [[ -z ${seen[$REPLY]} ]]; do
-      seen[$REPLY]=1
-      newfile=()
-      zstat -A newfile +link $REPLY 2>/dev/null
-      if [[ -n $newfile[1] ]]; then
-	REPLY=$newfile[1]
-      else
-	break
-      fi
-    done
-    if [[ $REPLY = */*[^/] && $REPLY != /[^/]# ]]; then
-      # Don't try this if there's a trailing slash or we're in
-      # the root directory.
-      nondir=${REPLY##*/#}
-      _canonical_paths_pwd ${REPLY%/#*}
-      REPLY+="/$nondir"
-    fi
-  fi
-}
-
 _canonical_paths_add_paths () {
   # origpref = original prefix
   # expref = expanded prefix
@@ -71,15 +24,7 @@ _canonical_paths_add_paths () {
   expref=${~origpref} 2>/dev/null
   [[ $origpref == (|*/). ]] && rltrim=.
   curpref=${${expref%$rltrim}:-./}
-  if [[ $expref:h == (.|..) ]]; then
-    _canonical_paths_pwd $expref:h
-    canpref=$REPLY/$expref:t
-  elif zstat $curpref >&/dev/null; then
-    _canonical_paths_get_canonical_path $curpref
-    canpref=$REPLY
-  else
-    canpref=$curpref
-  fi
+  canpref=$curpref:P
   [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/
   canpref+=$rltrim
   [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/
@@ -136,10 +81,7 @@ _canonical_paths() {
   if (( $__opts[(I)-N] )); then
     files=($@)
   else
-    for __index in $@; do
-      _canonical_paths_get_canonical_path $__index
-      files+=($REPLY)
-    done
+    files+=($@:P)
   fi
 
   local base=$PREFIX