DASH Shell discussions
 help / color / mirror / Atom feed
From: Harald van Dijk <harald@gigawatt.nl>
To: dash@vger.kernel.org
Cc: Jilles Tjoelker <jilles@stack.nl>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	jrnieder@gmail.com
Subject: Re: [PATCH] [PARSER] Remove backslash before } in double-quotes in variable
Date: Tue, 23 Nov 2010 19:45:13 +0059	[thread overview]
Message-ID: <4CEC0BD1.2070908@gigawatt.nl> (raw)
In-Reply-To: <20101121134222.GC17293@stack.nl>

On 21/11/10 14:41, Jilles Tjoelker wrote:
> The backslash prevents the closing brace from terminating the
> substitution, therefore it should be removed.

Thanks, that works great.

> Example:
>    printf "%s\n" ${$+\}} ${$+"\}"} "${$+\}}"
> should print } three times, without backslashes.

Some tests with different a few shells:

                                                     "${$+'\}'}"
                                              "${$+"\}"}"
                                       "${$+\}}"
                                ${$+'\}'}
                         ${$+"\}"}
                  ${$+\}}

bash           | }      \}     \}     \}     }      '\}'
pdksh          | }      \}     \}     }      \}     \}
ksh            | }      }      \}     }      }      '}'
dash (current) | }      \}     \}     \}     \}     '\}'
dash (patched) | }      }      \}     }      }      '}'

The one thing that I was a bit confused about was the difference between 
${$+'\}'} and ${$+"\}"}, but I do think that is correct: the backslash 
is used to see that the immediately following } is not a terminator, but 
the special rule allowing backslash before } to be removed in 
double-quoted strings in parameter expansions does not apply (there is 
no double-quoted string), so the backslash appears in the output as 
well. And since the last form uses a double-quoted string, the backslash 
gets removed there.

Cheers,
Harald

  parent reply	other threads:[~2010-11-23 18:44 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
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 [this message]
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=4CEC0BD1.2070908@gigawatt.nl \
    --to=harald@gigawatt.nl \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jilles@stack.nl \
    --cc=jrnieder@gmail.com \
    /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