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

Re: A way to find a bug (or explain a missuse of) realpath expansion?



On Tue, Apr 30, 2024 at 6:59 AM Marc Chantreux <mc@xxxxxxxxxx> wrote:
>
> The /usr shade of path will disapear from debian distribution

Can you provide a reference for this?  Web search is clogged with
reports of accidental deletions of the /usr tree, etc.

>         foo=( {/usr,}/bin )
>         print -l ${(u):-${foo%/}(:A)}

You're trying to use a glob qualifier form (:A) but you're not doing
globbing, you're doing parameter expansion.  Just use the
colon-modifier directly:

print -l ${(u):-${foo:A}}

> neither I can deal with backslashed twins.

The above handles that, too.  You don't need to explicitly remove the
trailing slashes yourself, :A will normalize them and then (u) will
collapse all four results to one.

> I still don't know how to give a closer look to the way zsh work to fix
> it by myself. To me the next step seems to be:
>
> * compile my own version of zsh with symbols (from apt source and
>   dpkg-buildpackage?)
> * run a gdb session and start to explore the code

I think that would only confuse you further.  That would be like
trying to learn programming by disassembling a compiler.

In the example here, I would say start by understanding the order of
operations from the "Expansion" chapter in the doc, and then look at
how you're transforming the steps to determine where you might be
changing to a different operation, and what that means for your
desired result.




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