On 6/16/25 12:51 PM, Lionel Cons wrote:
Why do these two lines differ in output? ${name} and ${name-} should
produce identical output if "name" exists as variable, or not?

They're not the same expansion, and the example you're using is not the
same as your question.

$  (name='bar" x' ; name="${name-//\"/}" ; printf "%q\n" "$name")
'bar" x'

In this expansion, you get the unsplit value of `name', since it's
set, and print it.

$  (name='bar" x' ; name="${name//\"/}" ; printf "%q\n" "$name")
'bar x'

In this expansion, you remove the double quote and print the result.

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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to