Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: globbing in conditional expressions
On Wed, 07 May 2014 14:41:01 +0200
Roman Neuhauser <neuhauser@xxxxxxxxxx> wrote:
> i was hoping i could combine conditional expressions with
> some globbing, but i'm struggling to find the proper syntax.
You need to do the globbing first. In conditional expressions you get
single-word expansion that doesn't do globbing.
> : 0 > ls fubar
> snafu
> : 0 > f=fubar(/F)
> : 0 > echo $f
> fubar(/F)
> : 0 > echo $~f
> fubar
> : 0 > (set -x; [[ -z $~f ]])
You'll need something like the following --- the (N) flag is needed if
you want the string to be empty if there's no match (unless you have the
NULL_GLOB option set, which isn't standard).
matches=(fubar(N/F))
[[ -z $matches ]]
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author