diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2016-10-31 17:12:00 -0700 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2016-11-01 12:45:24 -0700 |
commit | 4bc0d139113c8036be299cc3e0120b062d714579 (patch) | |
tree | b64bcb4945d965aca7a1164e4e4fa21747fdaf3f /Completion | |
parent | 4eed68e0bf1997f160d60c0892c0543a77ac497f (diff) | |
download | zsh-4bc0d139113c8036be299cc3e0120b062d714579.tar.gz zsh-4bc0d139113c8036be299cc3e0120b062d714579.tar.xz zsh-4bc0d139113c8036be299cc3e0120b062d714579.zip |
39797: obsolete the helper functions fixed by the previous two changes
Replacing them with the new ${var:P} modifier. Previous deltas may be useful for backport to zsh 5.2 and before.
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Unix/Type/_canonical_paths | 66 |
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 |