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

Re: _canonical_path not working on *BSD



On Wed, 26 Mar 2008 11:44:13 +0100
Baptiste Daroussin <baptiste.daroussin@xxxxxxxxx> wrote:
> Hi,
> 
> _canonical_path is not working on freebsd, it rely on readlink which  
> does work the same on BSD :
> on openbsd -q options doesn't exist : umount[tab] gives readlink:  
> unknown option -- q
> on freebsd readlink: illegal option -- q

Pea suggested just removing the -q, but probably we should also redirect
stderr:

Index: Completion/Unix/Type/_canonical_paths
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_canonical_paths,v
retrieving revision 1.1
diff -u -r1.1 _canonical_paths
--- Completion/Unix/Type/_canonical_paths	28 May 2006 18:36:06 -0000	1.1
+++ Completion/Unix/Type/_canonical_paths	26 Mar 2008 15:05:05 -0000
@@ -38,7 +38,8 @@
   files=($@)
 else
   for __index in $@; do
-    files+=$(readlink -qf $__index)
+    # BSD doesn't have -q, so redirect stderr.
+    files+=$(readlink -f $__index 2>/dev/null)
   done
 fi
 
@@ -48,7 +49,7 @@
   expref=${~origpref}
   [[ $origpref == (|*/). ]] && rltrim=.
   curpref=${${expref%$rltrim}:-./}
-  canpref=$(readlink -qf $curpref)
+  canpref=$(readlink -f $curpref 2>/dev/null)
   if [[ $? -eq 0 ]]; then
     [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/
     canpref+=$rltrim


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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