LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Bash 2 and shell case matching

[ILUG] Bash 2 and shell case matching

Niall niall at magicgoeshere.com
Mon Apr 17 20:30:22 IST 2000


Hi all,
	John Allen and I discussed this back and forth privately recently,
and I though I'd got a handle on it, but I haven't. It's to do with how bash
matches wildcard filespecs, and is seemingly related to the new shopt
command in Bash 2 and specifically the nocaseglob option. I jumped in here
when the action of the nullglob option bit me, but now it's the case thing
which is hurting me. I have a directory with some text files as below:

% ls *txt
All Haughey.txt       General Irish.txt     Scenes Foreign.txt
Business Foreign.txt  Politics Foreign.txt  Social Personalities.txt
Business Irish.txt    Politics Irish.txt    small.txt

I needed to do some operation on only those files beginning with capitals,
but for some reason I looked at what the expansion was before I did the work
which was just as well because:

% ls [A-Z]*txt
All Haughey.txt       General Irish.txt     Scenes Foreign.txt
Business Foreign.txt  Politics Foreign.txt  Social Personalities.txt
Business Irish.txt    Politics Irish.txt    small.txt

I didn't want small.txt here, nor did I expect it to match. This behaviour
is the same whether the shell option nocaseglob is set or not. If I have
only [A-S] instead of [A-Z] I get the behaviour I'd expect.

I get 

% shopt -s nocaseglob;ls [A-S]*txt
All Haughey.txt       General Irish.txt     Scenes Foreign.txt
Business Foreign.txt  Politics Foreign.txt  Social Personalities.txt
Business Irish.txt    Politics Irish.txt    small.txt

% shopt -u nocaseglob;ls [A-S]*txt
All Haughey.txt       General Irish.txt     Scenes Foreign.txt
Business Foreign.txt  Politics Foreign.txt  Social Personalities.txt
Business Irish.txt    Politics Irish.txt 



This looks awfully like a bug to me, and a major one, I'd say, as files may
be included (e.g. for deletion) where you'd not expect them to be.


Kindest regards,


Niall  O Broin




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell