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

Re: [Review Request] Arrays and their usage



> On 5/31/21, René Neumann <lists@xxxxxxxxx> wrote:
> >
> > Question: Is this the correct/zshonic way of doing this?

Using arrays, rather than repeatedly building strings that must be
split on spaces, is definitely the "zshonic" idiom.

> > I personally find the change of behavior by adding ( ) too easy to
> > overlook. Is there an alternative with ${(...)}?

I'm uncertain which change of behavior you mean?

On Sun, May 30, 2021 at 5:28 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> I would probably have written it like this
>
> local pkgs=( ${(f)"$(makepkg --blabla | sed blabla)"} )
> sudo pacman -S $DATABASE/$^pkgs

Of course it's possible to do this without the "pkgs" array:

sudo pacman -S $DATABASE/${^${(f)"$(makepkg --blabla | sed blabla)"}}

But you should do whichever you'll be able to understand when you come
back to it later.




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