[Wylug-help] Setting Default Variables in Shell Scripts

Smylers Smylers at stripey.com
Thu Jun 7 12:52:52 BST 2007


Aaron Crane writes:

> Smylers writes:
> 
> > Where is this documented?  In bash(1) searching for 'Assign Default
> > Values' suggests that this variant would work:
> > 
> >   : ${NAME:=Seymour}
> > 
> > -- and indeed it does.  But how come it also works without the (second)
> > colon?
> 
> Scroll back a few lines from that point in bash(1), and you find this
> note:
> 
>   When not performing substring expansion, bash tests for a parameter
>   that is unset or null; omitting the colon results in a test only for
>   a parameter that is unset.

Thank you!  I'd been searching for "="; it never occurred to me that I
should search for the ":" that isn't there (and especially not to search
for "colon" spelt out in full).

Smylers



More information about the Wylug-help mailing list