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

Re: array contains "foo"



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}



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