bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Locale not Obeyed by Parameter Expansion with Pattern Substitution


From: Chris Carlen
Subject: Locale not Obeyed by Parameter Expansion with Pattern Substitution
Date: Sun, 17 Nov 2019 01:25:31 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]