[PATCH] Drop multi-byte character in argstr when discard is on
Herbert Xu <[email protected]> Sat, 25 Apr 2026 10:48:38 +0800
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Apr 23, 2026 at 02:22:15PM +0000, Grégory Pakosz wrote:
>
> It seems that Dash regressed (but I don't know when).
>
> $ dash -c 'x=X; printf "before: %s (%d)\n" "$x" "${#x}"; x=${x:-↗};
> printf "after: %s (%d)\n" "$x" "${#x}"'
> before: ↗ (1)
> after: X↗ (2)
>
> I'm using Dash 0.5.13.2 on macOS, installed via Homebrew.
> The bug seems to be locale irrelevant.
Thank you. Please try this patch:
---8<---
The multi-byte character should not be copied to the destination
in argstr if the discard flag is enabled. Fix it.
Reported-by: Grégory Pakosz <[email protected]>
Fixes: 6c44f4ee0c2b ("parser: Add support for multi-byte characters")
Signed-off-by: Herbert Xu <[email protected]>
diff --git a/src/expand.c b/src/expand.c
index bbf8454..76e67ce 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -379,7 +379,8 @@ addquote:
if (c == CTLESC)
startloc += ml;
p += mb & 0xff;
- expdest = stnputs(p, ml, expdest);
+ if (!(flag & EXP_DISCARD))
+ expdest = stnputs(p, ml, expdest);
p += mb >> 8;
break;
case CTLESC:
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt