Re: anomalous behaviour of ls command

2018-01-30 Thread Ilkka Virta

On 30.1. 20:54, ken young wrote:

I have a directory with four files A Z a z only.
"ls [A-Z]" displays only 3 files A Z   z   ;a is missing
"ls [a-z]" displays only 3 files A   a z   ;Z is missing


Basically, your locale orders the letters as aAbBcC...yYzZ, so Z comes 
after z and [a-z] misses it. Similarly for a and [A-Z]. You can see the 
ordering if you do 'echo *' or such.


'shopt -s globasciiranges' should make [a-z] only match the 26 ASCII 
lowercase letters, and 'shopt -s nocaseglob' should make the globs match 
regardless of lettercase (it would also make a* match A).



--
Ilkka Virta / itvi...@iki.fi



Re: anomalous behaviour of ls command

2018-01-30 Thread Greg Wooledge
On Tue, Jan 30, 2018 at 01:54:36PM -0500, ken young wrote:
> uname output: Linux Microknoppix 4.12.7-64 #13 SMP PREEMPT Tue Aug 15 
> 04:56:38 CEST 2017 x86_64 GNU/Linux
> Machine Type: i686-pc-linux-gnu
> 
> Bash Version: 4.4
> Patch Level: 12
> Release Status: release
> 
> I have a directory with four files A Z a z only.
> "ls [A-Z]" displays only 3 files A Z   z   ;a is missing
> "ls [a-z]" displays only 3 files A   a z   ;Z is missing

The behavior of range expressions in globs depends on your locale
setting.  The legacy range expressions [A-Z] and [a-z] only work
the way you expect when your locale is set to "C" or "POSIX".

If you want to match only uppercase letters (whatever those are in
your locale), you must use [[:upper:]] instead.  To match only
lowercase letters (whatever those are), use [[:lower:]] instead.

See  for more details.

wooledg:~$ mkdir /tmp/x && cd "$_"
wooledg:/tmp/x$ touch A Z a z
wooledg:/tmp/x$ ls [A-Z]
A  z  Z
wooledg:/tmp/x$ ls [[:upper:]]
A  Z
wooledg:/tmp/x$ ls [[:lower:]]
a  z
wooledg:/tmp/x$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=



anomalous behaviour of ls command

2018-01-30 Thread ken young
Please find enclosed bashbug file.

From: knoppi
To: bug-bash@gnu.org,b...@packages.debian.org
Subject: [behaviour of ls]


Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-w_CE2V/bash-4.4=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall -no-pie 
-Wno-parentheses -Wno-format-security
uname output: Linux Microknoppix 4.12.7-64 #13 SMP PREEMPT Tue Aug 15 04:56:38 
CEST 2017 x86_64 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.4
Patch Level: 12
Release Status: release

Description:
[Detailed description of the problem, suggestion, or complaint.]
ls does not list the expected files

Repeat-By:
[Describe the sequence of events that causes the problem
to occur.]
I have a directory with four files A Z a z only.
"ls [A-Z]" displays only 3 files A Z   z   ;a is missing
"ls [a-z]" displays only 3 files A   a z   ;Z is missing

Fix:
[Description of how to fix the problem.  If you don't know a
fix for the problem, don't include this section.]