Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [Review Request] Arrays and their usage
- X-seq: zsh-users 26750
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: René Neumann <lists@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: [Review Request] Arrays and their usage
- Date: Sun, 30 May 2021 21:24:08 -0700
- Archived-at: <https://zsh.org/users/26750>
- In-reply-to: <CAHYJk3TNk-dPjz=iZwPxBCKpXFvHCxntfTetCdDmvsOehmS-wA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <26fc6ecd-4a05-e562-7274-ba045df536bf@necoro.eu> <CAHYJk3TNk-dPjz=iZwPxBCKpXFvHCxntfTetCdDmvsOehmS-wA@mail.gmail.com>
> 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