Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Untokenize before quoting unquoted literal values



I accidentally wrote git send-email -1
0001-Untokenize-before-quoting-unquoted-literal-values.patch instead
of just the filename (muscle memory echo from the git format-patch
-1), sorry about that.

On Sun, Jul 5, 2026 at 3:10 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> % print -r - ${(q+):-foo = bar}|xxd
> 00000000: 2766 6f6f 208d 2062 6172 270a            'foo . bar'.
> % print -r - ${(q+):-foo * bar}|xxd
> 00000000: 2766 6f6f 2087 2062 6172 270a            'foo . bar'.
> % print -r - ${(qqqq):-foo = bar}
> $'foo \215 bar'
> ---
>  Src/subst.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/Src/subst.c b/Src/subst.c
> index 9e846afa5c..196a1cd8e1 100644
> --- a/Src/subst.c
> +++ b/Src/subst.c
> @@ -4090,13 +4090,16 @@ colonsubscript:
>
>             if (quotemod > 0) {
>                 if (quotetype == QT_QUOTEDZPUTS) {
> -                   for (; *ap; ap++)
> +                   for (; *ap; ap++) {
> +                       untokenize(*ap);
>                         *ap = quotedzputs(*ap, NULL);
> +                   }
>                 } else if (quotetype > QT_BACKSLASH) {
>                     int sl;
>                     char *tmp;
>
>                     for (; *ap; ap++) {
> +                       untokenize(*ap);
>                         tmp = quotestring(*ap, quotetype);
>                         sl = strlen(tmp);
>                         *ap = (char *) zhalloc(pre + sl + post + 1);
> @@ -4136,10 +4139,12 @@ colonsubscript:
>                 val = dupstring(val), copied = 1;
>             if (quotemod > 0) {
>                 if (quotetype == QT_QUOTEDZPUTS) {
> +                   untokenize(val);
>                     val = quotedzputs(val, NULL);
>                 } else if (quotetype > QT_BACKSLASH) {
>                     int sl;
>                     char *tmp;
> +                   untokenize(val);
>                     tmp = quotestring(val, quotetype);
>                     sl = strlen(tmp);
>                     val = (char *) zhalloc(pre + sl + post + 1);
> --
> 2.38.1
>


-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author