Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _canonical_path not working on *BSD
- X-seq: zsh-workers 24754
- From: Pea <zsh@xxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: _canonical_path not working on *BSD
- Date: Wed, 26 Mar 2008 18:08:14 +0100
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <20080326164615.1d5893ed@news01>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: Raveland
- References: <20080326114413.80713vrmznwpnyuc@xxxxxxxxxxxxxxx> <080326083638.ZM16858@xxxxxxxxxxxxxxxxxxxxxx> <200803261540.m2QFeJmm017381@xxxxxxxxxxxxxx> <200803261604.m2QG41Ke017772@xxxxxxxxxxxxxx> <200803261621.m2QGLptV017966@xxxxxxxxxxxxxx> <20080326173824.0a55c00d@xxxxxxxxxxxxxxxxxxxxxx> <20080326164615.1d5893ed@news01>
Le Wed, 26 Mar 2008 16:46:15 +0000,
Peter Stephenson <pws@xxxxxxx> a écrit :
> On Wed, 26 Mar 2008 17:38:24 +0100
> Pea <zsh@xxxxxxxxxxxx> 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
>
>
This patch works fine for me on OpenBSD !!
Thanks.
--
Pierre-Emmanuel André <pea at raveland.org>
GPG key: 0x7AE329DC
Messages sorted by:
Reverse Date,
Date,
Thread,
Author