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-05 Tuesday at 04:57 +0000 Daniel Shahaf wrote:
> Feedback is sought for a proposed behaviour change to the shell.
> 
> Currently, the ':a' word modifier removes '..' component from a path —
> using a purely syntactic transformation, i.e., without consulting the
> filesystem at all — and ':A' does the same and then resolves symlinks
> [so no path component in the result is a symlink].
> 
> It has been proposed to change the semantics of :A to resolve symlinks
> first and '..' components second, like the realpath(3) library function
> does.
> 
> Under the incumbent semantics, $foo:A denotes the same file as $foo:a
> (but not necessarily the same file as $foo).  Under the proposed
> semantics, $foo:A denotes the same file as $foo (but not necesarily the
> same file as $foo:a).
> 
> Would this change be a good idea?
> 

If voting for two different solutions is permitted,
I would vote for either (1) or (2):


(1)
(1.1)  We have already modifier “:a” for “..” removal.
(1.2)  Introduce a new modifier just for resolving
       filereferences (“symlinks”).
By splitting the two actions of modifier “:A” we could have both,
(1.2) after or before (1.1), both with the performance advantage over
external “realpath”.  The need to think about the desired order would
automatically comply with the goal of “least surprise”.

(2)    Leave it as is, keep backward compatibility.
The inconsistency with “realpath” can be viewed as advantage:
Both (1.2) after or before (1.1) is possible, the former by using “:A”,
the latter by using external “realpath”.



Thanks for taking care and for this democratic approach.
-- 
Best regards
Roland Eggner

Attachment: signature.asc
Description: Digital signature



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