public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Juergen Daubert <j.daubert@posteo.de>
Cc: dash@vger.kernel.org
Subject: [PATCH] builtin: Keep backslash on quotes outside of dollarsq
Date: Mon, 6 Oct 2025 11:26:02 +0800	[thread overview]
Message-ID: <aOM2ykncn3sL2LsJ@gondor.apana.org.au> (raw)
In-Reply-To: <aOEPAl49li-HH7ou@jue>

Juergen Daubert <j.daubert@posteo.de> wrote:
> I'm using dash 0.5.13 with the two patches 
> 
>  [PATCH] expand: Fix off-by-one bug in expmeta
>  [PATCH] expand: Fix typo in pmatch for wildcard search
> 
> as /bin/sh and get the folling breaking while building 
> GNU inetutils:
> 
> ...
> make[2]: Entering directory '/tmp/inetutils/src/inetutils-2.6/src'
>  CC       hostname.o
>  CC       traceroute.o
>  CC       inetd.o
> <command-line>: error: expected expression before '/' token
> inetd.c:166:31: note: in expansion of macro 'PATH_INETDPID'
>  166 | static const char *pid_file = PATH_INETDPID;
>      |                               ^~~~~~~~~~~~~

Thanks for the report! This is due to an unintended change in behaviour
of echo '\"'.  Thie patch should fix the problem.

---8<---
Only dollar single quote should eat the backslash character before
a quote.  Make the skipping of the backslash conditional on mbchar
in conv_escape.

Reported-by: Juergen Daubert <j.daubert@posteo.de>
Fixes: 776424a8f915 ("parser: Add dollar single quote")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/src/bltin/printf.c b/src/bltin/printf.c
index ff576ff..106aecd 100644
--- a/src/bltin/printf.c
+++ b/src/bltin/printf.c
@@ -339,7 +339,7 @@ unsigned conv_escape(char *str0, char *out0, bool mbchar)
 
 	switch (ch) {
 	default:
-		if (ch == '"' || ch == '\'')
+		if (mbchar && (ch == '"' || ch == '\''))
 			break;
 
 		if (ch == 'U') {
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2025-10-06  3:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-04 12:11 bash 0.5.13: breaks buiding of inetutils Juergen Daubert
2025-10-06  3:26 ` Herbert Xu [this message]
2025-10-06 15:12   ` [PATCH] builtin: Keep backslash on quotes outside of dollarsq j.daubert

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=aOM2ykncn3sL2LsJ@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=j.daubert@posteo.de \
    /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