mike@x.co.uk (Mike Moore) (07/26/90)
In article <855@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: > >%: It turns out that something of the above becomes a new questions for > you unix wizards: Does anybody know a way to quote a "}" in the > context of a conditional expansion of a shell variable. What I'm > looking for is the following > > echo ${A:+'{}'} # echo '{}' only if A is not empty > > which works for non-empty A-s but fails otherwise: a single '}' > is echoed where IMHO nothing should appear. Note that the above > works if I use some intermediate variable: B={}; echo ${A+$B} > Or is it a bug of the shell that the above doesn't work as > expected? >-- >Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83 I haven't got the source code to /bin/sh, but I would say it's a bug because it doesn't matter how much you quote the first } it still gets used as the end marker for the substitution command. An alternative to assigning B={} is to use: ${A:+"\0173\0175"} or ${A:+{"\0175"}. -- -------------------------------------------------------------------------- Usual disclaimer..... etc | mike@x.co.uk True Intelligence is not knowing all the answers, | it's knowing the right questions. |