Home > OS >  Nested double quotes in parameter expansion
Nested double quotes in parameter expansion

Time:11-15

I was surprised that the following is a valid Parameter Expansion. Notice there are unescaped double quotes within double quotes:

result="${var1#"$var2"}"

Can someone please parse this for me?

CodePudding user response:

There are double quotes nested in curly brackets which is OK.

But none of them is needed in this case.

result=${var1#$var2}

works the same even for values containing spaces and newlines.

  • Related