From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13378 invoked from network); 26 Mar 2008 17:08:29 -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 17:08:29 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 37625 invoked from network); 26 Mar 2008 17:08:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Mar 2008 17:08:25 -0000 Received: (qmail 3335 invoked by alias); 26 Mar 2008 17:08:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24754 Received: (qmail 3321 invoked from network); 26 Mar 2008 17:08:21 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Mar 2008 17:08:21 -0000 Received: from puffy.raveland.org (puffy.raveland.org [195.200.166.230]) by bifrost.dotsrc.org (Postfix) with ESMTP id A287A8097826 for ; Wed, 26 Mar 2008 18:08:18 +0100 (CET) Received: from coredump.raveland.priv (bofh.pacwan.net [195.200.191.36]) by puffy.raveland.org (Postfix) with ESMTP id E659D713464; Wed, 26 Mar 2008 18:08:17 +0100 (CET) Date: Wed, 26 Mar 2008 18:08:14 +0100 From: Pea To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: _canonical_path not working on *BSD Message-ID: <20080326180814.35077d10@coredump.raveland.priv> In-Reply-To: <20080326164615.1d5893ed@news01> 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> <20080326164615.1d5893ed@news01> Organization: Raveland X-Mailer: Claws Mail 3.3.0 (GTK+ 2.12.7; i386-unknown-openbsd4.3) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV 0.91.2/6397/Wed Mar 26 17:06:49 2008 on bifrost X-Virus-Status: Clean Le Wed, 26 Mar 2008 16:46:15 +0000, Peter Stephenson a =E9crit : > On Wed, 26 Mar 2008 17:38:24 +0100 > Pea wrote: > > This almost works: > >=20 > > umount [TAB] gives me: > > [pea@coredump:~]% umount > > / /dev/sd0a /dev/svnd0a /home/pea > >=20 > >=20 > > umout /[TAB] gives me: > > [pea@coredump:~]% umount / > > / /dev/sd0a /dev/svnd0a /home/pea > >=20 > >=20 > > But umount /d[TAB] or umount /de[TAB] or umount /h[TAB] give me > > nothing... > > It worked with readlinks >=20 > Thanks for trying... looks like my assumption about the status test > was wrong. >=20 > Index: Completion/Unix/Type/_canonical_paths > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 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 @@ > =20 > shift 2 > =20 > -if (( ! $+commands[readlink] )); then > +if ! zmodload -F zsh/stat b:zstat 2>/dev/null; then > _wanted "$tag" expl "$desc" compadd $__gopts $@ && ret=3D0 > return ret > fi > =20 > +typeset REPLY > typeset -a matches files > =20 > +_canonical_paths_get_canonical_path() { > + typeset newfile > + typeset -A seen > + > + REPLY=3D$1 > + # Guard against loops. > + while [[ -z ${seen[$REPLY]} ]]; do > + seen[$REPLY]=3D1 > + newfile=3D$(zstat +link $REPLY 2>/dev/null) > + if [[ -n $newfile ]]; then > + REPLY=3D$newfile > + else > + break > + fi > + done > +} > + > + > if (( $__opts[(I)-N] )); then > files=3D($@) > else > for __index in $@; do > - files+=3D$(readlink -qf $__index) > + _canonical_paths_get_canonical_path $__index > + files+=3D($REPLY) > done > fi > =20 > @@ -48,13 +68,16 @@ > expref=3D${~origpref} > [[ $origpref =3D=3D (|*/). ]] && rltrim=3D. > curpref=3D${${expref%$rltrim}:-./} > - canpref=3D$(readlink -qf $curpref) > - if [[ $? -eq 0 ]]; then > - [[ $curpref =3D=3D */ && $canpref =3D=3D *[^/] ]] && canpref+=3D/ > - canpref+=3D$rltrim > - [[ $expref =3D=3D *[^/] && $canpref =3D=3D */ ]] && origpref+=3D/ > - matches+=3D(${${(M)files:#$canpref*}/$canpref/$origpref}) > + if zstat $curpref >&/dev/null; then > + _canonical_paths_get_canonical_path $curpref > + canpref=3D$REPLY > + else > + canpref=3D$curpref > fi > + [[ $curpref =3D=3D */ && $canpref =3D=3D *[^/] ]] && canpref+=3D/ > + canpref+=3D$rltrim > + [[ $expref =3D=3D *[^/] && $canpref =3D=3D */ ]] && origpref+=3D/ > + matches+=3D(${${(M)files:#$canpref*}/$canpref/$origpref}) > for subdir in $expref?*(@); do > _canonical_paths_add_paths ${subdir/$expref/$origpref} add > done >=20 >=20 This patch works fine for me on OpenBSD !! Thanks. --=20 Pierre-Emmanuel Andr=E9 GPG key: 0x7AE329DC