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

Re: [bug] :P modifier and symlink loops



2020-02-02 08:10:21 +0000, Daniel Shahaf:
[...]
> However, in ${${:-"/tmp/loop/../foo"}} we can't meet the postcondition.
> I think our options are either to throw an exception, like a glob with
> no matches does, or to keep the additional components verbatim, as you
> suggest.
> 
> Intuitively I lean towards the first option.  We aren't a CGI script,
> where PATH_INFO is to be expected.  If we can't return a path without
> dot and dot-dot components and without symlinks, we should raise an
> error rather than continue silently. However, I'm open to alternatives.

That works for me, I agree it's a pathological condition that
may be worth reporting to the user, and to do that, there's
probably no other alternative than to exit the current shell
process.

> I think the first option could be implemented along the lines of:
> 
> 1. Call realpath($arg).
> 2. If it returns ELOOP,

... and doesn't end in /..

the . path components would have to be removed first as well.

> call realpath(${arg:h}) and append "/${arg:t}".

And what if *that* realpath() fails with ELOOP? Do we carry on
with $arg:h:h?

> 3. Otherwise, throw an exception (i.e., set errflag).
[...]

-- 
Stephane



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