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


Groups > gnu.bash.bug > #15600 > unrolled thread

Locale not Obeyed by Parameter Expansion with Pattern Substitution

Started byChris Carlen <crobc@sbcglobal.net>
First post2019-11-17 01:25 -0800
Last post2019-11-17 01:25 -0800
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#15600 — Locale not Obeyed by Parameter Expansion with Pattern Substitution

FromChris Carlen <crobc@sbcglobal.net>
Date2019-11-17 01:25 -0800
SubjectLocale not Obeyed by Parameter Expansion with Pattern Substitution
Message-ID<mailman.1723.1573998600.13325.bug-bash@gnu.org>
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).

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web