bug-bash
[Top][All Lists]
Advanced

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

Re: Bash glob range [0-5] in UTF-8 locale misses ¹, ² & ³


From: Greg Wooledge
Subject: Re: Bash glob range [0-5] in UTF-8 locale misses ¹, ² & ³
Date: Mon, 8 Sep 2025 07:22:37 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Mon, Sep 08, 2025 at 04:59:48 -0400, Grisha Levit wrote:
> Alternatively, we could check that the _range_ ends are ASCII characters
> (and, depending on the desired behavior, check the character being tested
> as well) before disabling locale-aware collation.

This one makes the most sense to me -- the first half, I mean.

With globasciiranges on, we want [0-5] to match *only* the characters
0, 1, 2, 3, 4 and 5.  We want to disable locale-aware collation for all
characters when matching against this range, so that characters like ⁴
(superscript 4) are not matched.  If locale-aware collation is allowed
between 0 and ⁴, and between ⁴ and 5, then we get a false match.
I think that's what's happening currently.

hobbit:/tmp/x$ ls
1  2  ²  3  ⁴  ⁵
hobbit:/tmp/x$ shopt -u globasciiranges
hobbit:/tmp/x$ echo [0-5]
1 2 ² 3 ⁴
hobbit:/tmp/x$ shopt -s globasciiranges
hobbit:/tmp/x$ echo [0-5]
1 2 3 ⁴

Superscript 2 is correctly excluded, but superscript 4 is incorrectly
included.



reply via email to

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