Re: ${name} vs ${name-} with ${...//...}

2025-06-16 Thread Chet Ramey
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="

Re: ${name} vs ${name-} with ${...//...}

2025-06-16 Thread Zachary Santer
On Mon, Jun 16, 2025 at 1:57 PM Zachary Santer wrote: > > You can't combine multiple forms of parameter expansion into one thing > like this. If name is unset, "${name-//\"/}" will do what the > ${parameter-word} expansion does and expand to //"/. > > If you want the combined effect of multiple fo

Re: ${name} vs ${name-} with ${...//...}

2025-06-16 Thread Greg Wooledge
On Mon, Jun 16, 2025 at 18:51:23 +0200, 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? > > $ (name='bar" x' ; name="${name-//\"/}" ; printf "%q\n" "$name") > 'bar" x' > $ (name='bar" x' ;

Re: ${name} vs ${name-} with ${...//...}

2025-06-16 Thread Zachary Santer
On Mon, Jun 16, 2025 at 1:25 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? > > $ (name='bar" x' ; name="${name-//\"/}" ; printf "%q\n" "$name") > 'bar" x' > $ (name='bar" x' ; name="