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

Re: Test if parameter is set



On Tue, 19 Apr 2011 18:48:57 +0200
Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx> wrote:
> how can I test if a parameter is set?

if (( ${+VAR} )); then
   ...

is the zsh-specific answer.  However, you can do this in a more standard
way, should you wish, with

if [[ -n ${VAR+1} ]]; then
   ...

(note no ":").

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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