[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "$@" vs. nounset

From: Mike Frysinger
Subject: Re: "$@" vs. nounset
Date: Mon, 29 Jun 2009 11:54:40 -0400
User-agent: KMail/1.11.4 (Linux/2.6.30; KDE/4.2.4; x86_64; ; )

On Monday 29 June 2009 04:54:52 Yang Zhang wrote:
> Hi, I like using nounset for stricter scripts, but an annoyance is that
> anytime I use "$@" and it's empty, I get an error, when (to me,
> cognitively) it is not "unset" (as in someone *forgot* to set it), it's
> just an empty, which is a common case (IIRC, in bash, variables set to
> empty arrays and unset variables are the same).
> As a result I'm forced to use "${@:-}" or something like that everywhere
> I use "$@" (which is really everywhere).  Is there any other way around
> this?  Any way to get a more selective nounset?  Thanks in advance.

if you search the archives, i think the previous discussion on this topic said 
bash-4's behavior needed to change here

does something like this at the top of the script work ?
[ $# -eq 0 ] && set --

Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]