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

Re: [[ -f file* ]]



Matt Wozniski <godlygeek@xxxxxxxxx>:
> On Mon, May 18, 2009 at 5:14 AM, Atom Smasher wrote:
> > if i want to test for the presence of one or more files matching a certain
> > pattern, it seems non-trivial to do it with the normal "test" or conditional
> > expressions.
> ...
> > is there a better way?
> 
> Well, off the top of my head, I can think of
> 
> [ -n "$(print -- test*(N))" ]
> 
> but even that seems inelegant; I'm sure someone can chime in with
> something better.

How about this:

[snip]
set -- test*(N)
(( $# > 0 ))
[snap]

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925



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