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: How to convert a path to the correct case


> On Wed, 14 Sep 2005, dalewking wrote:
> 
> > Cygwin itself is case preserving, but case insensitive. Other tools are
> > not so flexible on case. In my case I have some issues with incorrect
> > case and my makefile.
> >
> > Consider if I had a directory /foo/BAR. Cygwin will let you actually do
> > "cd /Foo/bar" and work happily. Pwd will actually return "/Foo/bar"
> > instead of the real path in this case.
> >
> > It would be really helpful to have a way given a string like "/Foo/bar"
> > to convert that to the real correct case "/foo/BAR".
> >
> > But I'm having trouble finding an easy, convenient way to do that. As I
> > said pwd doesn't do it nor does cygpath.
> >
> > One way that works is to turn the path into a pattern. You can do "ls
> > /Foo/bar*" but that will return multiple strings if there is more than
> > one file that starts with BAR. You can do "ls /Foo/ba[r]" but then how
> > do I easily add the brackets into the string? I've tried various things
> > with find, but none do the conversion.
> >
> > Anyone have a good idea how to do this conversion.
> 
> <http://cygwin.com/cygwin-ug-net/using-cygwinenv.html>, and search for
> check_case.  You want "check_case:adjust".  Don't let the warning scare
> you off... :-D

I've seen that before and the warning does scare me off. The other problem is
that it doesn't seem to work as advertised:

$ printenv CYGWIN
tty ntea check_case:adjust

$ cd /Foo/bar

$ pwd
/Foo/bar

> Alternatively, if you *are* scared off by the warning, you could do
> 
> ls -1 /Foo/bar* | head

I think you wanted a -1 on the head command. But apparently I was wrong on how
well adding the patttern to the path works. It only fixes the one part of the
path that has the pattern. So what you gave will return /Foo/BAR and not
/foo/BAR. In order to use the patterns I would have to make each part of the
path into a pattern (e.g. ls /Foo*/bar*).

One possibility I am working on is one that requires turning on the extglob
shell option. You can then do:

  ls /@(Foo)/@(bar)

@(pattern) says match one occurrence of pattern. This command would be a little
easier to construct from make, but sure seems like an awfully bad hack.


> On Wed, 14 Sep 2005, dalewking wrote:
> 
> > Cygwin itself is case preserving, but case insensitive. Other tools are
> > not so flexible on case. In my case I have some issues with incorrect
> > case and my makefile.
> >
> > Consider if I had a directory /foo/BAR. Cygwin will let you actually do
> > "cd /Foo/bar" and work happily. Pwd will actually return "/Foo/bar"
> > instead of the real path in this case.
> >
> > It would be really helpful to have a way given a string like "/Foo/bar"
> > to convert that to the real correct case "/foo/BAR".
> >
> > But I'm having trouble finding an easy, convenient way to do that. As I
> > said pwd doesn't do it nor does cygpath.
> >
> > One way that works is to turn the path into a pattern. You can do "ls
> > /Foo/bar*" but that will return multiple strings if there is more than
> > one file that starts with BAR. You can do "ls /Foo/ba[r]" but then how
> > do I easily add the brackets into the string? I've tried various things
> > with find, but none do the conversion.
> >
> > Anyone have a good idea how to do this conversion.
> 
> <http://cygwin.com/cygwin-ug-net/using-cygwinenv.html>, and search for
> check_case.  You want "check_case:adjust".  Don't let the warning scare
> you off... :-D
> 
> Alternatively, if you *are* scared off by the warning, you could do
> 
> ls -1 /Foo/bar* | head

--
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]