From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13333 invoked from network); 26 Mar 2008 16:46:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 26 Mar 2008 16:46:39 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 30485 invoked from network); 26 Mar 2008 16:46:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Mar 2008 16:46:36 -0000 Received: (qmail 19724 invoked by alias); 26 Mar 2008 16:46:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24753 Received: (qmail 19710 invoked from network); 26 Mar 2008 16:46:33 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Mar 2008 16:46:33 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 5F6618097826 for ; Wed, 26 Mar 2008 17:46:27 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly26d.srv.mailcontrol.com (MailControl) with ESMTP id m2QGkL0A011635 for ; Wed, 26 Mar 2008 16:46:24 GMT Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Wed, 26 Mar 2008 16:46:15 +0000 Date: Wed, 26 Mar 2008 16:46:15 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: _canonical_path not working on *BSD Message-ID: <20080326164615.1d5893ed@news01> In-Reply-To: <20080326173824.0a55c00d@coredump.raveland.priv> References: <20080326114413.80713vrmznwpnyuc@bapt.selfip.org> <080326083638.ZM16858@torch.brasslantern.com> <200803261540.m2QFeJmm017381@news01.csr.com> <200803261604.m2QG41Ke017772@news01.csr.com> <200803261621.m2QGLptV017966@news01.csr.com> <20080326173824.0a55c00d@coredump.raveland.priv> Organization: CSR X-Mailer: Claws Mail 3.3.1 (GTK+ 2.12.5; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 26 Mar 2008 16:46:15.0554 (UTC) FILETIME=[E835EE20:01C88F60] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.68.0.136 X-Virus-Scanned: ClamAV 0.91.2/6397/Wed Mar 26 17:06:49 2008 on bifrost X-Virus-Status: Clean On Wed, 26 Mar 2008 17:38:24 +0100 Pea wrote: > This almost works: > > umount [TAB] gives me: > [pea@coredump:~]% umount > / /dev/sd0a /dev/svnd0a /home/pea > > > umout /[TAB] gives me: > [pea@coredump:~]% umount / > / /dev/sd0a /dev/svnd0a /home/pea > > > But umount /d[TAB] or umount /de[TAB] or umount /h[TAB] give me > nothing... > It worked with readlinks Thanks for trying... looks like my assumption about the status test was wrong. 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 16:43:46 -0000 @@ -27,18 +27,38 @@ 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 +typeset REPLY typeset -a matches files +_canonical_paths_get_canonical_path() { + typeset newfile + typeset -A seen + + REPLY=$1 + # Guard against loops. + while [[ -z ${seen[$REPLY]} ]]; do + seen[$REPLY]=1 + newfile=$(zstat +link $REPLY 2>/dev/null) + if [[ -n $newfile ]]; then + REPLY=$newfile + else + break + fi + done +} + + if (( $__opts[(I)-N] )); then files=($@) else for __index in $@; do - files+=$(readlink -qf $__index) + _canonical_paths_get_canonical_path $__index + files+=($REPLY) done fi @@ -48,13 +68,16 @@ expref=${~origpref} [[ $origpref == (|*/). ]] && rltrim=. curpref=${${expref%$rltrim}:-./} - canpref=$(readlink -qf $curpref) - if [[ $? -eq 0 ]]; then - [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/ - canpref+=$rltrim - [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/ - matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) + if zstat $curpref >&/dev/null; then + _canonical_paths_get_canonical_path $curpref + canpref=$REPLY + else + canpref=$curpref fi + [[ $curpref == */ && $canpref == *[^/] ]] && canpref+=/ + canpref+=$rltrim + [[ $expref == *[^/] && $canpref == */ ]] && origpref+=/ + matches+=(${${(M)files:#$canpref*}/$canpref/$origpref}) for subdir in $expref?*(@); do _canonical_paths_add_paths ${subdir/$expref/$origpref} add done -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070