Re: Quoted closing brace in variable default expansion

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

 



On Sat, 20 Nov 2010, Harald van Dijk wrote:
> On 19/11/10 14:53, Herbert Xu wrote:
> > Harald van Dijk<harald@xxxxxxxxxxx>  wrote:
> > >    sh -c 'echo "${x:-\}}"'
> >
> > If you need to print anything involving a backspace you should
> > use printf and not echo.
>
> It's true that backslashes should not be passed to echo, but assuming
> unset or empty x, "${x:-\}}" should expand to "}", and that is all echo
> should see.

You seem to have a point there:

,----[ http://opengroup.org/onlinepubs/007908799/xcu/chap2.html ]
| single-quotes cannot be used to quote the "}" within ${...}; for
| example:
|
| unset bar
| foo="${bar-'}'}"
|
| is invalid because the ${...} substitution contains an unpaired
| unescaped single-quote. The backslash can be used to escape the "}" in
| this example to achieve the desired result:
|
| unset bar
| foo="${bar-\}}"
`----


Cheers,

-- 
Cristian
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux