Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _canonical_path not working on *BSD



On Mar 26, 11:44am, Baptiste Daroussin wrote:
}
} _canonical_path is not working on freebsd, it rely on readlink

Try this.  I don't actually have any mount points that are symlink
targets so it's hard to test, but I think this is right:

--- ../zsh-forge/current/Completion/Unix/Type/_canonical_paths  2006-05-28
11:36:06.000000000 -0700
+++ ../zsh-4.0/Completion/Unix/Type/_canonical_paths    2008-03-26
08:31:42.000000000 -0700
@@ -27,7 +27,7 @@
 
 shift 2
 
-if (( ! $+commands[readlink] )); then
+if ! zmodload -F zsh/stat b:zstat 2>/dev/null; then
   _wanted "$tag" expl "$desc" compadd $__gopts $@ && ret=0
   return ret
 fi
@@ -38,7 +38,7 @@
   files=($@)
 else
   for __index in $@; do
-    files+=$(readlink -qf $__index)
+    files+=$(zstat +link $__index)
   done
 fi
 
@@ -48,8 +48,8 @@
   expref=${~origpref}
   [[ $origpref == (|*/). ]] && rltrim=.
   curpref=${${expref%$rltrim}:-./}
-  canpref=$(readlink -qf $curpref)
-  if [[ $? -eq 0 ]]; then
+  canpref=$(zstat +link $curpref)
+  if [[ -n "$canpref" ]]; then
     [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/
     canpref+=$rltrim
     [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/



Messages sorted by: Reverse Date, Date, Thread, Author