zsh-users
 help / color / mirror / code / Atom feed
* Re: array contains "foo"
       [not found] <pdy98830621028bbe6b7bc50d64@[192.168.1.2]>
@ 2005-03-26 22:32 ` Andrey Borzenkov
  2005-03-26 23:14   ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Borzenkov @ 2005-03-26 22:32 UTC (permalink / raw)
  To: zsh-users; +Cc: Dave Yost

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[Redirected to zsh-users]

On Saturday 26 March 2005 23:53, Dave Yost wrote:
> Hi.
>
> I've beat my head against the zsh manual for an hour now, and I can't
> see how to test whether
>
> x=(foo bar)
>
> contains foo (yes) or contains xyz (no).
>

{pts/1}% x=(foo bar)
{pts/1}% echo ${${x[(r)foo]}:+yes}
yes
{pts/1}% echo ${${x[(r)xyz]}:-no}
no

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCReMXR6LMutpd94wRAvujAJ0YV/OKpI6/qbtVQ3mkJBGfr3x+lwCgwy0J
j0QcqPMA84ZkKhk7ZEb1p/w=
=EJVK
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: array contains "foo"
  2005-03-26 22:32 ` array contains "foo" Andrey Borzenkov
@ 2005-03-26 23:14   ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2005-03-26 23:14 UTC (permalink / raw)
  To: zsh-users

On Mar 27,  1:32am, Andrey Borzenkov wrote:
}
} {pts/1}% x=(foo bar)
} {pts/1}% echo ${${x[(r)foo]}:+yes}
} yes
} {pts/1}% echo ${${x[(r)xyz]}:-no}
} no

This is my favorite:

setopt extendedglob
x=(foo bar)
echo ${${${x[(r)foo]}/?##/yes}:-no}
echo ${${${x[(r)xyz]}/?##/yes}:-no}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-26 23:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <pdy98830621028bbe6b7bc50d64@[192.168.1.2]>
2005-03-26 22:32 ` array contains "foo" Andrey Borzenkov
2005-03-26 23:14   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).