This is the mail archive of the cygwin@cygwin.com 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]

Re: Case resolution when searching $PATH


On Mon, Mar 26, 2001 at 02:06:24PM -0800, Brett wrote:
> I need to figure out how to make the shell (I use tcsh) impartial to
> case when it searches the $PATH variable for an executable.  I am

tcsh is case sensitive. You can change that slightly by

	set complete = enhance

Take a look into the man page.

> using build scripts which I have no control over which reference MS
> exe's which happen to have all upper case filenames.  Unfortunately
> for me, the scripts use all lower case when calling the executables.
>  This means that the exe's are not found in my path.

You should better use bash for scripting.

> If 'which' behaves like the shell when the shell searches for an
> exec, then I am confused as to its behavior.  Look at this example:
> 
> If I have a file /path/file.exe and /path is in $PATH and I type
> 'which file.exe' I usually get the correct output.  If instead I
> type 'which FILE.EXE' it can't find it.  But if I give which the
> path to the file like so: 'which /path/FILE.EXE' it can resolve it. 
> Why the inconsistency?

Which foo results in searching `foo' in the shell's internal hash table.

If you give a path (which bin/foo) the shell's hash table is not used
but it calls `stat(2)' immediately. Since Windows file systems are case
insensitive the Cygwin internal call finds a file called FOO.

It's not inconsistent, it's simply another mechanism which is used
and that's an obvious behaviour, IMO.

> Another thing, notice above I said I usually get the correct output.
>  I have xemacs in my path and it is found if I type 'which xemacs'
> but NOT 'which xemacs.exe' EVEN THOUGH that is the actual filename
> (case and all) and it is marked executable.  As usual, if I give
> which the full path to xemacs.exe it will recognize that name.  What
> good is a path search if you have to know the path before you
> search???

If you want to change the behaviour of tcsh, feel free to submit a
patch to the tcsh maintainers.

> I have looked through the man page for tcsh and can't find any
> mention of a way to ignore case when searching the path.  I assume
> this is done internal to the shell and I could not circumvent it
> with a script (to lowercase the filename beforehand).

Except for `set complete = enhance'.

> Is there a way I can still get these build script calls resolved
> even though the case doesn't match?

Use bash as script shell. Personally I'm using tcsh as interactive
shell but I would never use it as script shell since the script
language is, uhm, ...

Anyway, if you want to have portable scripts use plain bourne shell
syntax or at least only bash extensions if you really need them.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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