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

Re: Wildcards in path question



Clint Olsen wrote:
>Thanks for your help getting wildcards in my path.  I was wondering how I
>might be able to use them so that they are added to my path iff they
>existed.  We have a very heterogenous environment here and certain
>directories (like /opt) exist on some of the machines.  Otherwise, the
>non-existence causes the expansion to barf out.  I'd rather it fail
>silently somehow to allow the sourcing of my environment to continue.

The NULL_GLOB option causes glob patterns that don't match anything to
expand to nothing, rather than causing an error.  This can be turned on
for a single glob pattern by using the (N) modifier:

path=( "$path[@]" /opt/*/bin(N) )

-zefram



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