filename pattern case-insensitive, but why?
Hello, If I try something like: $ touch a.c b.c A.c $ ls [a-z]*.c a.c A.c b.c then I get A.c in the output, even if no capital letters are to be found. Looking thru the docs I have currently: $ shopt autocd off cdable_vars off cdspell off checkhash off checkjobs off checkwinsizeon cmdhist on compat31off compat32off dirspelloff dotglob off execfailoff expand_aliases on extdebugoff extglob on extquoteon failgloboff force_fignore on globstaroff gnu_errfmt off histappend off histreedit off histverify off hostcompleteoff huponexit off interactive_commentson lithist off login_shell off mailwarnoff no_empty_cmd_completion off nocaseglob off nocasematch off nullgloboff progcompon promptvars on restricted_shelloff shift_verbose off sourcepath on xpg_echooff Doing the same in ksh and dash works as expected. Tnx Thomas -- View this message in context: http://www.nabble.com/filename-pattern-case-insensitive%2C-but-why--tp25530647p25530647.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Strange compgen behaviour
Hi fellow bashers! I am trying to add some completion to a command. The completion should list all movies I have in a certain folder, regardless if I am in that folder or not. I have kind of got it to work in several variants but all have some issue. The current problem I am looking at is very strange. I have isolated it down to a strange behaviour with compgen. Let's see if I can describe it clearly enough: zf contains the list of movie file names zc is the current input, in my case "/home/mathias/Videos/movies/H" $ compgen -W "${zf}" -- ${zc} Here is the output: /home/mathias/Videos/movies/Harry.Potter... /home/mathias/Videos/movies/Harry.Potter... /home/mathias/Videos/movies/Harry.Potter... /home/mathias/Videos/movies/Harry.Potter... /home/mathias/Videos/movies/Harry.Potter... /home/mathias/Videos/movies/Brazil (Terry Gilliam, 1985).avi /home/mathias/Videos/movies/Ice.Age.2... /home/mathias/Videos/movies/True.Blood.S01... /home/mathias/Videos/movies/True.Blood.S01... I have shortended the names to make it more readable and also removed some hits. The main issue here is how for example the line with Brazil can match the input. Same goes for True Blood. And, to make it even more scary, an input such as "/home/mathias/Videos/movies/B" does not match the Brazil line. What's up with this? My bash version: $ bash --version GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) Running under Ubuntu 8.04. Thanks! /Mathias PS. If you like I can post the whole function that takes care of the completion, but I think it is not important here. PPS. The main cause of the issues I have seens to be that some file names have spaces, and as I said earlier, every way I have tried, even the ones that workes so so, have some issues. Any tips to get this relatively fool proof?
Re: filename pattern case-insensitive, but why?
On Tue, Sep 22, 2009 at 02:36:30AM -0700, thahn01 wrote: > > Hello, If I try something like: > > $ touch a.c b.c A.c > $ ls [a-z]*.c > a.c A.c b.c > > then I get A.c in the output, even if no capital letters are to be found. The "[a-z]" range expression matches characters between a and z in the current locale's collation order. The collation order for en_US.UTF-8 and other locales has uppercase and lowercase alphabetic characters together. So in those locales your range includes 'a' through 'z' and 'A' through 'Y'. You can change the locale to "C" or "POSIX" to get plain ascii collation order. You can see the collation order using the sort command. for c in {32..126}; do eval printf '"%c - %d\n"' $(printf "$'%o'" $c) $c;done | sort -k 1.1,1.1 for c in {32..126}; do eval printf '"%c - %d\n"' $(printf "$'%o'" $c) $c;done | LANG=C sort -k 1.1,1.1 The collation order lists 'a' before 'A', but actually lets a later character break a tie between otherwise equal uppercase and lowercase characters. Sort will arrange 'a1', 'A1', 'a2', and 'A2' with the '1' vs. '2' characters acting as a tiebreaker. -- Mike Stroyan