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

Re: FAQ : how to check for existence of a file ABC*



Helmut Jarausch wrote:
> sorry if this is a FAQ (I just couldn't find it)
>
> I like to check if there is any file matching a given file pattern
> e.g.  XX*
>
> My problem is,
>
> if NULL_GLOB is unset the shell bails out if no such file exists;
> but if NULL_GLOB is set, then the test   [[ -f XX* ]] is invalid since
> XX* expands to a null string.

It's a question that comes up every now and then, but I don't think it's
in the FAQ.

Here's an approach using a helper function:
  <http://www.zsh.org/mla/users/2009/msg00509.html>

And if you don't want to introduce a function, you may want to use
something along the lines of this:
  <http://www.zsh.org/mla/users/2009/msg00512.html>

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