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

Re: realpath(3), symlinks, '..' components, and the ':A' word modifier

Roland Eggner wrote on Tue, Jul 05, 2016 at 14:54:30 +0200:
> (1.2)  Introduce a new modifier just for resolving
>        filereferences (“symlinks”).

This seems like a reasonable way forward.

To everyone who asked about compatibility: under the existing semantics
of :A, «$foo» and «$foo:A» might denote different files.  (Not just
different dirents, but different inodes, or possibly pathnames under
different mountpoints.)  That does not seem like a useful transformation;
it has no equivalent in other languages (including but not limited
to C); it's different from other common modifiers ('cat $foo:h/$foo:t'
== 'cat $foo:r.$foo:e' == 'cat $foo' != 'cat `f $foo:A`'); and it makes
it impossible to use the :A modifier to resolve symlinks in arguments
that may contain '..' segments (so if someone thinks of :A as "zsh's
interface to realpath(3)", their code would be broken).

So yes, backwards compatibility is important; I'm normally the first to
speak in its favour.  But when a behaviour has no obvious use-case, and
is unexpected to the point of possibly causing uses of it to be buggy,
then I do ask whether that documented behaviour is a feature or
a (documented) bug.

So, bottom line...  it seems the consensus on both lists is not to risk
breaking compatibility here, and to add another :x modifier letter
instead (as suggested by Roland here and by pws/Bart in workers/38798 et

I will add that to my list, or if someone beats me to implementing it
that's fine too.

Thanks all,


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