Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filename generation: instruct zsh not to follow symbolic links?
On 2026-07-17 12:24:34 -0700, Bart Schaefer wrote:
> On Fri, Jul 17, 2026 at 11:57 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> >
> > > Hm, I don't think :A would resolve links in the final component of the
> > > path, only in <dir> along the way? Can you provide a counter-example?
> > > Or am I not understanding the concern?
> >
> > % mkdir lfoo
> > % mkdir lfoo/baz
> > % ln -s baz/bing lfoo/foo
> > % a=lfoo/foo
> > % touch lfoo/baz/bing
> > % echo $a:A
> > /tmp/a/lfoo/baz/bing
> > % echo $a:A:h $a:a:h
> > /tmp/a/lfoo/baz /tmp/a/lfoo
> > % echo $a:h:A $a:h:a
> > /tmp/a/lfoo /tmp/a/lfoo
>
> Ah, I see. Where the last component is itself symlinked to a
> directory. I could envision wanting that to go either way, but :h:A
> is probably closer to what Vincent wanted.
Indeed. With
nosym() { [[ $REPLY:a:h == $REPLY:A:h ]] || typeset -g reply=() }
mkdir a b c
touch a/foo b/bar
ln -s bar b/foo
ln -s ../a/foo c
I get
% ls -l */foo(+nosym)
-rw-r--r-- 1 vinc17 vinc17 0 2026-07-18 01:55:06 a/foo
lrwxrwxrwx 1 vinc17 vinc17 3 2026-07-18 01:55:06 b/foo -> bar
instead of
-rw-r--r-- 1 vinc17 vinc17 0 2026-07-18 01:55:06 a/foo
lrwxrwxrwx 1 vinc17 vinc17 3 2026-07-18 01:55:06 b/foo -> bar
lrwxrwxrwx 1 vinc17 vinc17 8 2026-07-18 01:55:06 c/foo -> ../a/foo
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author