Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: (z) expansion flag do not always return an array
- X-seq: zsh-users 27388
- From: Vincent Bernat <bernat@xxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: (z) expansion flag do not always return an array
- Date: Mon, 29 Nov 2021 18:44:18 +0100
- Archived-at: <https://zsh.org/users/27388>
- In-reply-to: <CAN=4vMpHw6m23qLyy3kurDgXvs1nRW6XAs3FEUQc7wX-Jpzysw@mail.gmail.com> (Roman Perepelitsa's message of "Mon, 29 Nov 2021 17:34:14 +0100")
- List-id: <zsh-users.zsh.org>
- References: <m3k0grdlls.fsf@luffy.cx> <CAN=4vMpHw6m23qLyy3kurDgXvs1nRW6XAs3FEUQc7wX-Jpzysw@mail.gmail.com>
❦ 29 November 2021 17:34 +01, Roman Perepelitsa:
>> Is there an easy way to know if something is an array or a string?
>> I am using subscripting for that but maybe there are better ways.
>
> If you had a parameter, you could use ${(t)foo} or $parameters[foo] to
> find its type. However, if you had a parameter you wouldn't have this
> problem to begin with.
Thanks for the tips!
> foo=(${(z)...})
>
> Here foo is always an array.
Yes, that's what I have done.
--
Let the machine do the dirty work.
- The Elements of Programming Style (Kernighan & Plauger)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author