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

Re: Stopping functions breaking



> I want it to cd to any directory beginning fred, if there 0 or more
> than 1 matches I wish to carry on in the script.
>
> However whatever I try 0 or no matches breaks the script.

Set the no_nomatch option, then the failed glob won't cause a fatal error.
The cd will fail, but won't stop later things working.

The best way to do this is probably to add

setopt localoptions nonomatch

at the top of the function.  This will ensure the options are restored
when the function exits.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



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