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

Re: (z) expansion flag do not always return an array



> On 29 November 2021 at 16:50 Lawrence Velázquez <larryv@xxxxxxx> wrote:
> On Mon, Nov 29, 2021, at 10:31 AM, Vincent Bernat wrote:
> > The (z) expansion flag is documented to return an array
> 
> Is it?  The 5.8 man page does not mention "array" even once.

Indeed, there's not really any notion of "returning an array".  There's
just the question of how something is treated at a particular part
of parameter expansion.  Forcing something to be treated in a
particular way by tweaking the expansion is possible, forcing
a particular value always to be treated in some way regardless
of context isn't, to the best of my knowledge.  The context always
has the last say --- consider quoting, and the flags to circumvent
quoting, for example.  They're all (over the top metaphor coming)
breadcrumbs to lead us of the labyrinth that's ended up at a
corner.

More generally, return values and explicit expression typing are things
shells, including zsh, are very bad at; it's particularly annoying with
zsh, however, owing to the complexities you can get into, and
nested parameters are one of the worst examples.

Feel free to find a counterexample, obviously.

pws




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