On Mon, Oct 21, 2024 at 06:01:53AM +0100, Harald van Dijk wrote: > > This particular use of echo with a backslash character used to work the same > way across shells and is widely used in configure scripts in a large number > of packages (specifically: any that use AC_SUBST_FILE). It was changed by > commit 776424a8 (parser: Add dollar single quote) without that commit > indicating that this would change; are you really sure this should not be > viewed as a bug? The impact will be massive. Fair enough. This behaviour should be reverted. ---8<--- A lot of scripts (in particular, autoconf) relies on echo keeping undefined backslash sequences intact. Preserve this behaviour by only interpreting the few sequences required for dollar single quote. Repoted-by: Дилян Палаузов <dilyan.palauzov@xxxxxxxxx> Fixes: 776424a8f915 ("parser: Add dollar single quote") Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> diff --git a/src/bltin/printf.c b/src/bltin/printf.c index 2c18e93..46c6295 100644 --- a/src/bltin/printf.c +++ b/src/bltin/printf.c @@ -339,8 +339,8 @@ unsigned conv_escape(char *str0, char *out0, bool mbchar) switch (ch) { default: if (!isodigit(ch)) { - value = ch ?: '\\'; - str -= !ch; + value = '\\'; + str--; break; } @@ -428,6 +428,12 @@ hex: ch = 8; goto hex; + case '\\': + case '\"': + case '\'': + value = ch; + break; + case 'a': value = '\a'; break; /* alert */ case 'b': value = '\b'; break; /* backspace */ case 'e': value = '\033'; break; /* <ESC> */ -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt