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

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



On 2016-07-07 10:20:31 -0700, Bart Schaefer wrote:
> On Jul 7,  2:00am, Daniel Shahaf wrote:
> } To everyone who asked about compatibility: under the existing semantics
> } of :A, "$foo" and "$foo:A" might denote different files.
> 
> But that implies that "$foo" and "$foo:a" might also denote different
> files, so why is *that* a useful transformation?

IMHO, the only useful transformation is to the same file (the usual
realpath).

Note that some scripts may use ":A" thinking that one would get the
same file. So, changing the behavior may also fix these scripts!

> } 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
> } seq).
> 
> There's no letter to use that won't in some way be confuse-able with a
> parameter expansion flag, so here are some ideas:
> 
> :L - mnemonic "link" - corresponds to "ls -L"
> :R - mnemonic "real" - think of realpath()
> :P - mnemonic "path" - the other half of realpath(), and also in a
>                        certain way comparable to the (P) parameter
> 		       flag in that it interprets the path name as
> 		       a further path name and yields the file at
> 		       the other path

If you do not want to change the behavior of ":A", then ":R" is
probably the best one. ":L" would definitely be a bad choice as
it could be confused with "realpath -L" from GNU coreutils, which
does the opposite (the default being "realpath -P", so using ":P"
could be OK too, where "P" means "physical").

In any case, the documentation should be clarified.

-- 
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 / AriC project (LIP, ENS-Lyon)



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