DASH Shell discussions
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: dash@vger.kernel.org
Subject: Re: Quoted closing brace in variable default expansion
Date: Sat, 13 Nov 2010 10:41:47 -0600	[thread overview]
Message-ID: <20101113164147.GB5535@burratino> (raw)
In-Reply-To: <4CDEBC7B.5050805@gigawatt.nl>

Hi Herald,

Harald van Dijk wrote:

>   $ 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.

The answer depends on how portable the script is meant to be.  If
the goal is to be portable to shells implementing future versions of
the POSIX standard, there seems to be have been an interpretation[1]
approved for the next major revision:

 http://austingroupbugs.net/view.php?id=221
 note #399

which would make the example nonconformant because there are an odd
number of unescaped double-quotes before the first unescaped closing
brace.

See http://thread.gmane.org/gmane.comp.shells.dash/262/focus=263 for
a nice summary (thanks, Jilles!).

Hope that helps,
Jonathan

  reply	other threads:[~2010-11-13 16:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13 16:28 Quoted closing brace in variable default expansion Harald van Dijk
2010-11-13 16:41 ` Jonathan Nieder [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101113164147.GB5535@burratino \
    --to=jrnieder@gmail.com \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox