Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Speaking of _canonical_paths ...
- X-seq: zsh-workers 39797
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Speaking of _canonical_paths ...
- Date: Mon, 31 Oct 2016 16:36:44 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=zInL2i99DV1C5y5+C1wyB87QHylcsBMuUx975gcNDbg=; b=QNkA8wfDdu/myMgS0dY+bUcVhlqDB7ONLsL5O7GRcSdTtTLRIdsDQK+CJu0gdVBslv OyWKWhM9JtCALJXti/VmBGM5Niqa6GlU0MiJ2KFuoqScvM5VZJUoCMp1c6Vu2Zu4Hxql X1jZ55Lt1oXKtYHfM/PZbSnQh6+EqBxm6Awak0fk5xnEuHh3H6dEcvnpo8mLdn2lMYEE 27/GKxu6gRTP7iYNJHJAH66qndG/Iqa8XeBUSlquCYsBZ2KSyQBoSbjbnR0HWduhkP9S 0TnkNlDVAGyIIV2kzKE3I+ixQv1AXbpn/ajXTqTqaE4ms/JHr3YDoB8nPxODoGDixnrc jZmQ==
- In-reply-to: <161031143109.ZM21081@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <161031143109.ZM21081@torch.brasslantern.com>
[Taking a long time for my email to reach the list, again.]
On Oct 31, 2:31pm, Bart Schaefer wrote:
} Subject: Speaking of _canonical_paths ...
}
} Is there anything _canonical_paths_get_paths does that isn't now handled
} by ${noncanonical_path:P} ?
So as far as I can tell, these helper functions are obsolete now.
diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths
index 4b6b0c0..6eab7b6 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author