1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix expansion of multibyte character after $1 - $9, $?, etc (#102)

A multibyte character immediately following an expansion of a
single-character name, e.g. $1 through $9, $?, $-, etc. was
corrupted when in a UTF-8 locale, e.g.:

    $ set -- foo; echo "$1テスト"
    foo?スト

Prior discussion:
https://www.mail-archive.com/ast-users@lists.research.att.com/msg01060.html
https://bugzilla.redhat.com/show_bug.cgi?id=1256495

src/cmd/ksh93/sh/macro.c:
- Apply a Red Hat patch by Paulo Andrade that avoids calling
  fcmbget() if backtracking more than one byte might be required.

src/cmd/ksh93/tests/basic.c:
- Test "テスト" following expansion of "$1", "$?" and "$#".

Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
Marc Wilson 2020-07-31 17:12:45 -07:00 committed by GitHub
parent 02a14ff9b7
commit 4144f404ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View file

@ -1506,7 +1506,10 @@ retry1:
default:
goto nosub;
}
c = fcmbget(&LEN);
if(type)
c = fcmbget(&LEN);
else
c = fcget();
if(type>M_TREE)
{
if(c!=RBRACE)