This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Normalized directory name


Tim McDaniel <tmcd <at> panix.com> writes:

> For tidiness, if nothing else, I'd like to get the normalized form, in
> much the same way how, in CMD, I can do
>      E:\>cd cm\buildutil
> and have the prompt become
>      E:\CM\BuildUtil>

In the case of cd, I'm not going to patch bash to do this by default.  However, 
you may be able to figure out how to write a shell function that uses bash's 
case-insensitive globbing to get something close to what you want:

$ shopt -s nocaseglob
$ echo src SRC sr[c] SR[C]
src SRC src src

So, given a name you want to normalize, find a way to rewrite it as a shell 
glob (easiest way to avoid the glob expanding into multiple files is converting 
one letter into a one-byte charset).  Seems like it would be an easy sed script 
to write to do that, which in turn can be wrapped by shell functions.  But 
beware that with cygwin 1.7, you can have directories which are case sensitive, 
in which case the glob may return multiple files.

-- 
Eric Blake




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]