DASH Shell discussions
 help / color / mirror / Atom feed
* Quoted closing brace in variable default expansion
@ 2010-11-13 16:28 Harald van Dijk
  2010-11-13 16:41 ` Jonathan Nieder
  0 siblings, 1 reply; 12+ messages in thread
From: Harald van Dijk @ 2010-11-13 16:28 UTC (permalink / raw)
  To: dash

Hi all,

It's probably best to start with the example:

   $ bash -c 'echo "${x:-"}"}"'
   }
   $ ksh -c 'echo "${x:-"}"}"'
   }
   $ dash -c 'echo "${x:-"}"}"'
   dash: 1: Syntax error: Unterminated quoted string
   $ busybox sh -c 'echo "${x:-"}"}"'
   sh: syntax error: unterminated quoted string

It looks like dash and other ash derivatives stop the expansion with the 
first }, instead of the first unquoted }. I'm getting confused trying to 
figure out whether this is a bug in dash or in the script relying on it.

A slightly modified example:

   $ dash -c 'echo "${x-"_{x}_"}"'
   dash: 1: Syntax error: Unterminated quoted string
   $ dash -c 'echo ${x-"_{x}_"}'
   _{x_}

I don't understand how the last line works. The } is printed after the 
_, so the } that is printed must be the final }, and the } directly 
following the x stops the variable default. But this would lead to two 
double quote characters which have no way of matching up, yet no syntax 
error is given.

Could you clarify?

Cheers,
Harald

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-03-11 18:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-13 16:28 Quoted closing brace in variable default expansion Harald van Dijk
2010-11-13 16:41 ` Jonathan Nieder
2010-11-13 17:29   ` Harald van Dijk
2010-11-19 13:54     ` Herbert Xu
2010-11-20  0:43       ` Harald van Dijk
2010-11-20 20:57         ` Cristian Ionescu-Idbohrn
2010-11-21 13:42         ` [PATCH] [PARSER] Remove backslash before } in double-quotes in variable Jilles Tjoelker
2010-11-21 16:35           ` Jonathan Nieder
2010-11-23 18:46           ` Harald van Dijk
2011-03-10  8:59           ` Herbert Xu
2011-03-11 18:32             ` Jilles Tjoelker
2010-11-13 17:51   ` Quoted closing brace in variable default expansion Jilles Tjoelker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox