Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15600

Locale not Obeyed by Parameter Expansion with Pattern Substitution

From Chris Carlen <crobc@sbcglobal.net>
Newsgroups gnu.bash.bug
Subject Locale not Obeyed by Parameter Expansion with Pattern Substitution
Date 2019-11-17 01:25 -0800
Message-ID <mailman.1723.1573998600.13325.bug-bash@gnu.org> (permalink)
References <0acc4767-e87f-f163-b39e-f137effdfea2.ref@sbcglobal.net> <0acc4767-e87f-f163-b39e-f137effdfea2@sbcglobal.net>

Show all headers | View raw


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

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Locale not Obeyed by Parameter Expansion with Pattern Substitution Chris Carlen <crobc@sbcglobal.net> - 2019-11-17 01:25 -0800

csiph-web