[lug] What the heck can I use ${VAR:-} for?
Jeffrey Haemer
jeffrey.haemer at gmail.com
Wed Apr 16 11:44:32 MDT 2008
Sean,
[Sound of hand smacking forehead.]
Of course! Thanks. Cool new trick internalized.
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
>
--
Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell]
http://goyishekop.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20080416/ea4ac83b/attachment.html>
More information about the LUG
mailing list