bug-bash
[Top][All Lists]
Advanced

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

nocaseglob doesn't always work as expected.


From: Alexey Vinogradov
Subject: nocaseglob doesn't always work as expected.
Date: Mon, 4 Oct 2010 20:14:32 +0700

It seems that ranged filename substitution sometimes doesn't work as
expected.
A couple of illustrations.

Source dir:

address@hidden:/tmp$ ls -la
...
-rw-r--r--  1 root     root           66 2010-09-21 08:54 ahello.txt
drwxr-xr-x  2 root     root            6 2010-09-18 13:09 bigstore
-rw-------  1 alexey   alexey    1611084 2010-09-29 18:19 clipboardcache
-rw-------  1 alexey   alexey    1611084 2010-09-29 18:19 clipboardcache-1
-rw-------  1 alexey   alexey    1611084 2010-09-29 18:19 clipboardcache-2
-rw-------  1 alexey   alexey    1611624 2010-09-29 18:19 clipboardcache-3
-rw-------  1 alexey   alexey          1 2010-10-04 18:31 cLnlY6
-rw-------  1 alexey   alexey          6 2010-10-04 18:31
Code::Blocks-alexey
drwx------  2 alexey   alexey         27 2010-09-03 01:17
codeblocks_dbgrpt-30651-20100903T011749
-rw-------  1 alexey   alexey          0 2010-09-13 15:29 codeblocksIJ8lud
srwx------  1 alexey   alexey          0 2010-10-04 18:31 CODEBLOCKS.socket
-rw-------  1 alexey   alexey          0 2010-09-03 01:17 codeblocksWrgEbU
drwxr-xr-x  3 alexey   alexey         16 2010-08-29 18:02 context
drwxr-xr-x  3 alexey   alexey       4096 2010-09-27 19:55 data
...

(I've included only files begin with "b" and "c/C")

Well, let us run:
address@hidden:/tmp$ shopt -u nocaseglob; shopt -s nullglob; for a in
[b-c]* ; do echo $a; done
bigstore
clipboardcache
clipboardcache-1
clipboardcache-2
clipboardcache-3
cLnlY6
codeblocks_dbgrpt-30651-20100903T011749
codeblocksIJ8lud
codeblocksWrgEbU
context

-- All as expected.
Another turn:

address@hidden:/tmp$ shopt -u nocaseglob; shopt -s nullglob; for a in
[B-C]* ; do echo $a; done
clipboardcache
clipboardcache-1
clipboardcache-2
clipboardcache-3
cLnlY6
Code::Blocks-alexey
codeblocks_dbgrpt-30651-20100903T011749
codeblocksIJ8lud
CODEBLOCKS.socket
codeblocksWrgEbU
context

Note: the nocaseglob is unset. Both letters in the range are actually latin.
Here is the prof:
echo "BC" | hd
00000000  42 43 0a                                          |BC.|

But the range search here is thow out only non-capital "bigstore" from the
listing, and still included both-cased files begin with c/C.
The fact that 'c' is in the range "B-C" looks really strange. I would expect
that this range contains only "B" and C" letters.

However, when directly enumerating the letters, all works ok:

address@hidden:/tmp$ shopt -u nocaseglob; shopt -s nullglob; for a in [BC]*
; do echo $a; done
Code::Blocks-alexey
CODEBLOCKS.socket

----------------
bash --version
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>

cat /etc/issue
Ubuntu 10.04.1 LTS \n \l

uname -a
Linux ubuntu64 2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010
x86_64 GNU/Linux


reply via email to

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