Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Check existence of an element of an array (a FAQ?)
- X-seq: zsh-users 12887
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: Check existence of an element of an array (a FAQ?)
- Date: Fri, 30 May 2008 09:53:08 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <tkrat.6fc8d798a167c9eb@xxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <tkrat.6fc8d798a167c9eb@xxxxxxxxxxxxxxxxxxx>
On Fri, May 30, 2008 at 10:40:30AM +0200, Helmut Jarausch wrote:
[...]
> Is there an elegant way (i.e. without a loop) to
> get the following action
>
> Special_Users=('you','me',......)
>
> U='nobody'
>
> if $U in $Special_Users
> # do something
> fi
[...]
if (($Special_Users[(Ie)$U])); then
# do something
fi
Note that the (e) flag is a recent addition to zsh. You can
ommit it, but then $U is taken as a pattern.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author