[lug] What the heck can I use ${VAR:-} for?

Jarrar Jaffari jarrar.jaffari at gmail.com
Wed Apr 16 11:40:49 MDT 2008


Sean,

You are correct, I just tested that. BTW the mode that you were talking
about is "set -u".

Jarrar

On Wed, Apr 16, 2008 at 11:31 AM, Sean Reifschneider <jafo at tummy.com> wrote:

> Jeffrey Haemer wrote:
> >    if [ "${BOOTUP:-}" != "verbose" ]; then
> >
> > What's this mean?  Specifically, why's it different from this?
> >
> >    if [ "$BOOTUP" != "verbose" ]; then
>
> There is a mode you can run the shell in, which is off by default, in
> which
> referencing an unset variable is an error.  The default is that accessing
> an unset variable results in an empty string.  So, if this mode is set,
> doing:
>
>   [ "$BOOTUP" != verbose ] && echo true
>
> will result in an error.  Where:
>
>   [ "${BOOTUP:-}" != verbose ] && echo true
>
> will not.
>
> Sean
> --
> Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
> tummy.com, ltd. - Linux Consulting since 1995: Ask me about High
> Availability
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20080416/8818abb9/attachment.html>


More information about the LUG mailing list