Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: sh command bogus output in UTF-8 text
On Thu, 6 Feb 2020 at 12:14, Robert Elz <kre%munnari.oz.au@localhost> wrote:
>
> If you could try the following patch to sh and let me know if
> you see any further problems, I'd appreciate it (it will take
> me a couple more days to complete testing and commit this, as
> even though the patch is very small, and affects almost nothing
> in sh, this is the kind of change that can produce unexpected
> side effects in the most bizarre circumstances).
I can confirm with this patch /bin/sh behaves as well as all the
others now - for me. Copy/paste of the patch text failed for some
reason, I manually applied the changes.
...
$ sh sh-command-utf8-testing-2
に кирилица
....
>
> Thanks,
>
> kre
>
>
> Index: expand.c
> ===================================================================
> RCS file: /cvsroot/src/bin/sh/expand.c,v
> retrieving revision 1.136
> diff -u -u -r1.136 expand.c
> --- expand.c 14 Oct 2019 13:34:14 -0000 1.136
> +++ expand.c 6 Feb 2020 12:06:31 -0000
> @@ -148,7 +148,7 @@
> {
>
> herefd = fd;
> - expandarg(arg, NULL, 0);
> + expandarg(arg, NULL, EXP_HEREDOC);
> xwrite(fd, stackblock(), expdest - stackblock());
> }
>
> @@ -307,7 +307,7 @@
> had_dol_at = 0;
> break;
> case CTLESC:
> - if (quotes || ISCTL(*p))
> + if (!(flag & EXP_HEREDOC) && (quotes || ISCTL(*p)))
> STPUTC(c, expdest);
> c = *p++;
> STPUTC(c, expdest);
> Index: expand.h
> ===================================================================
> RCS file: /cvsroot/src/bin/sh/expand.h,v
> retrieving revision 1.24
> diff -u -u -r1.24 expand.h
> --- expand.h 18 Nov 2018 17:23:37 -0000 1.24
> +++ expand.h 6 Feb 2020 12:06:31 -0000
> @@ -59,6 +59,7 @@
> #define EXP_IN_QUOTES 0x40 /* don't set EXP_IFS_SPLIT again */
> #define EXP_GLOB 0x80 /* perform filename globbing */
> #define EXP_NL 0x100 /* keep CRTNONL in output */
> +#define EXP_HEREDOC 0x200 /* expanding heredoc, no further processing */
>
> #define EXP_FULL (EXP_SPLIT | EXP_GLOB)
> #define EXP_QNEEDED (EXP_GLOB | EXP_CASE | EXP_REDIR)
>
>
--
----
Home |
Main Index |
Thread Index |
Old Index