Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Test if parameter is set
- X-seq: zsh-users 15964
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>
- Subject: Re: Test if parameter is set
- Date: Tue, 19 Apr 2011 19:19:14 +0200
- Cc: zsh-users@xxxxxxx
- In-reply-to: <iokedv$c96$1@dough.gmane.org> (Thorsten Kampe's message of "Tue, 19 Apr 2011 18:48:57 +0200")
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <iokedv$c96$1@dough.gmane.org>
Thorsten Kampe wrote:
> how can I test if a parameter is set?
>
> Like in...
>
> if $VAR_IS_SET; then
> print Variable is set
> else
> print Variable is not set
> fi
In zsh:
if (( ${+parameters[foo]} )); then
: set
else
: unset
fi
In POSIX shells:
if [ x${foo+set} = xset ]; then
: set
else
: unset
fi
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