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

Re: globbing in a for loop may prematurely exit script when sourcing a zsh script



On Jul 31, 2013, at 2:02 AM, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:

> The right thing to do here is tell the shell to expand the pattern to an
> empty string if there are no matches.  You can do this without changing
> any options by appending (N) to the pattern, i.e.
> 
>  for f in /custom/zsh.d/*.zsh(N); do
> 
> This behaves as if the NULL_GLOB option was set for that pattern.  In
> zsh (but not necessarily other shells) a "for" loop over an empty
> expansion does nothing.


Excellent, this is exactly what I was looking for! Thank you, I knew there must
be some way to do it.


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