On 09/04/2012 05:13 AM, Roman Rakus wrote: > Hi, > Petr, adding to cc: list, found behaviour not documented, neither in man > page nor bash ref manual: > ${par-word} will do expansion of par, and if the par is unset it is > substituted by word. It is different from ${par:-word}, where word is > used when par is unset or null. > > Is it undocumented and deprecated, like $[]? Or just undocumented?
It is fully documented, and required by POSIX. Read two lines above: When not performing substring expansion, using the forms documented below, bash tests for a parameter that is unset or null. Omitting the colon results in a test only for a parameter that is unset. ${parameter:-word} Use Default Values. If parameter is unset or null, the expanâ sion of word is substituted. Otherwise, the value of parameter is substituted. It's a shame that the form ${parameter-word} is not called out more directly in a form easy to search for, and that you have to read in two places to piece things together yourself; but it IS supported and documented. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature