Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux safire 3.13.0-24-generic #47-Ubuntu SMP Fri May 2
23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 0
Release Status: release
Description:
UTF-8 multibyte char string split into bytes rather than characters.
Repeat-By:
#!/bin/bash
shopt -s extglob
LC_ALL="en_US.UTF-8"
# E.g., normal/expected behavior:
# Create a string:
A=abc
# Replace left virtual empty strings with spaces, putting separated
# chars into positional parameters, then print them quoted:
set -- ${A//?()/ }
echo "${@@Q}" #-> 'a' 'b' 'c'
# E.g., abnormal behavior:
# write 'REVERSE PILCROW SIGN' to B, then repeat as above:
printf -v B '\u204B'
set -- ${B//?()/ }
echo "${@@Q}" #-> $'\342' $'\201' $'\213'
# NOTE: Since there is only one character (under the UTF-8 locale),
# this should have set only the first positional parameter with the
# character REVERSE PILCROW SIGN, not split it into bytes (AFAIK).