Bernd Eggink schrieb:
With LANG=de_DE.UTF-8, the second output in the following sequence is wrong:

    item=(typeset text)
    txt=$'-\303\274'            # u-umlaut
    item.text="$txt"
    print -- "${item.text}"     # -\303\274 (OK)
    eval "arr[0]=$item"
    print -- "${arr[0].text}"   # -\374 (WRONG)

Whith LANG=C, both are equal and correct. The error seems to occur whenever a character not in the [:word:] class is followed by a multi-byte character.

Here is a variant with a different behaviour.

set -x
item=(typeset text)
#item.text=$'\303\274'      # u-umlaut
item.text="-ü"              # u-umlaut typed in
print -- "${item.text}"     # \303 \274 (OK)
eval "arr[0]=$item"
print -- "${arr[0].text}"   # \374 (ERROR)
eval "txt=${arr[0]}"
print -- $txt

Output piped through od -tx1c:

+ typeset item.text
+ item.text=$'-\374'
+ print -- $'-\374'
+ eval $'arr[0]=(\n\ttext=$\'-\\374\'\n)'
+ arr[0].text='-ü'
+ print -- '-ü'
+ eval txt=$'(\n\ttext=\'-ÿ\'\n)'
./moco[10]: eval: syntax error at line 2: `end of file' unexpected
+ print --
0000000 2d c3 bc 0a 2d fc 0a 0a
          - 303 274  \n   - 374  \n  \n
0000010

In the line preceding the 'syntax error' message, the u-umlaut has changed into a y with an umlaut sign.

Regards,
Bernd

--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to