bug-bash
[Top][All Lists]
Advanced

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

Re: parameter expansion with `:` does not work


From: Chet Ramey
Subject: Re: parameter expansion with `:` does not work
Date: Wed, 7 Jul 2021 18:51:24 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 7/7/21 6:48 PM, lisa-asket@perso.be wrote:


I have some difficulty understanding the difference between ${parameter:-word} 
and ${parameter:=word}, and when it is appropriate to use one as opposed to the 
other.

Dennis Williamson succinctly summarized the differences.

${parameter:-word}
If parameter is unset or null, the expansion of word is substituted.

${parameter:=word}
If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted.

The key difference is in the first sentence of each description.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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