zsh-users
 help / color / mirror / code / Atom feed
* realpath(3), symlinks, '..' components, and the ':A' word modifier
@ 2016-07-05  4:57 Daniel Shahaf
  2016-07-05 12:54 ` Roland Eggner
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Daniel Shahaf @ 2016-07-05  4:57 UTC (permalink / raw)
  To: zsh-users

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?

----- Forwarded message from Daniel Shahaf <d.s@daniel.shahaf.name> -----

> Date: Fri, 10 Jun 2016 17:36:23 +0000
> From: Daniel Shahaf <d.s@daniel.shahaf.name>
> To: zsh-workers@zsh.org
> Subject: [PATCH 2/3] Fix the ':A' word modifier on paths with '..' components.
> Message-ID: <1465580184-3095-2-git-send-email-danielsh@tarsus.local2>
> X-Seq: 38650
> 
> This is an incompatible change; see the test and docs changes for details.
> 
> Daniel
> 
>  Doc/Zsh/expn.yo   |  6 ++++--
>  README            |  9 +++++++++
>  Src/hist.c        | 22 ++++++++++------------
>  Test/D02glob.ztst |  6 ++++++
>  4 files changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
> index c6e7b6f..50b8479 100644
> --- a/Doc/Zsh/expn.yo
> +++ b/Doc/Zsh/expn.yo
> @@ -225,9 +225,11 @@ intervening directories do not exist.
>  )
>  item(tt(A))(
>  As `tt(a)', but also resolve use of symbolic links where possible.
> -Note that resolution of `tt(..)' occurs em(before) resolution of symbolic
> -links.  This call is equivalent to tt(a) unless your system has the
> +This call is equivalent to tt(a) unless your system has the
>  tt(realpath) system call (modern systems do).
> +
> +em(Note): In zsh 5.2 and earlier, resolution of `tt(..)' occurred em(before)
> +resolution of symbolic links.
>  )
>  item(tt(c))(
>  Resolve a command name into an absolute path by searching the command
> diff --git a/README b/README
> index d5343db..84bb6bc 100644
> --- a/README
> +++ b/README
> @@ -79,6 +79,15 @@ Other aspects of EXIT trap handling have not changed --- there is still
>  only one EXIT trap at any point in a programme, so it is not generally
>  useful to combine POSIX and non-POSIX behaviour in the same script.
>  
> +4) On systems that have the realpath(3) library function, the ':A' word
> +modifier now resolves symbolic links before '..' path components.  This
> +could lead to different, but usually more desirable, results: the
> +tranformed value will now always identify the same directory entry as the
> +the pre-transformation value.
> +
> +The behaviour of 5.2 and older can be achieved by chaining modifiers:
> +'<expression>:a:A'.
> +
>  Incompatibilities between 5.0.8 and 5.2
>  ---------------------------------------
>  
> diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
> index 8618378..dc1a655 100644
> --- a/Test/D02glob.ztst
> +++ b/Test/D02glob.ztst
> @@ -670,3 +670,9 @@
>   () { set -- ${PWD}/$^@; print -l -- $@:A } glob.tmp/nonexistent/foo/bar/baz
>  0:modifier ':A' doesn't require existence
>  *>*/glob.tmp/nonexistent/foo/bar/baz
> +
> + ln -s dir3/subdir glob.tmp/link
> + () { print ${1:A} } glob.tmp/link/../../hello
> + rm glob.tmp/link
> +0:modifier ':A' resolves symlinks before '..' components
> +*>*glob.tmp/hello
> 

----- End forwarded message -----


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2016-07-21  9:29 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05  4:57 realpath(3), symlinks, '..' components, and the ':A' word modifier Daniel Shahaf
2016-07-05 12:54 ` Roland Eggner
2016-07-05 13:24 ` Vadim Zeitlin
2016-07-06 15:15   ` Filipe
     [not found] ` <20160705125430.GA29959__3886.85245202414$1467723835$gmane$org@mobil.systemanalysen.net>
2016-07-07  2:00   ` Daniel Shahaf
2016-07-07 17:20     ` Bart Schaefer
     [not found]       ` <20160705093321.79d7c4bc@pwslap01u.europe.root.pri>
2016-07-12  7:58         ` Next release (5.3) Roman Neuhauser
2016-07-12 16:40           ` Bart Schaefer
2016-07-12 20:23             ` Oliver Kiddle
2016-07-13  2:56               ` Filipe Silva
2016-07-13  4:45                 ` Bart Schaefer
2016-07-13  5:09                   ` Filipe Silva
2016-07-13  9:32               ` Peter Stephenson
2016-07-13  9:59                 ` Peter Stephenson
2016-07-13 16:35                   ` Bart Schaefer
2016-07-13 16:59                     ` Peter Stephenson
2016-07-13 17:50                       ` Bart Schaefer
     [not found]                 ` <20160713105910.2b33701c__17004.846657119$1468404086$gmane$org@pwslap01u.europe.root.pri>
2016-07-17 14:59                   ` Daniel Shahaf
     [not found]               ` <20160713103233.14bfd05a__26126.9551389434$1468402471$gmane$org@pwslap01u.europe.root.pri>
2016-07-17 14:59                 ` [PATCH] improve :A docs (was: Re: Next release (5.3)) Daniel Shahaf
     [not found]                 ` <20160717145931.GA4859__10178.6871244714$1468767679$gmane$org@tarsus.local2>
2016-07-20  6:54                   ` Daniel Shahaf
2016-07-13  7:41             ` Next release (5.3) Roman Neuhauser
2016-07-13 17:36               ` Bart Schaefer
2016-07-20 13:05             ` Vincent Lefevre
2016-07-20 14:00               ` Vincent Lefevre
2016-07-20 14:15                 ` Peter Stephenson
2016-07-20 14:19                   ` Peter Stephenson
     [not found]                 ` <20160720151517.6a833f2c__37436.2382958227$1469024822$gmane$org@pwslap01u.europe.root.pri>
2016-07-21  5:40                   ` Daniel Shahaf
2016-07-21  9:19                     ` Peter Stephenson
2016-07-21  3:50               ` Bart Schaefer
     [not found]           ` <160712094017.ZM17395__33553.1437922784$1468341719$gmane$org@torch.brasslantern.com>
2016-07-13  5:00             ` Daniel Shahaf
     [not found]       ` <20160712075849.GG1537__20664.8654224866$1468310440$gmane$org@isis.sigpipe.cz>
2016-07-13  5:01         ` Daniel Shahaf
2016-07-20 12:44       ` realpath(3), symlinks, '..' components, and the ':A' word modifier Vincent Lefevre

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).