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: Batch files


Jan Vicherek wrote:
> 
>   Hmm, executing "foo.bat" works even without performing the three steps
> below, but executing "foo" (where "foo.bat" is in the path), doesn't work
> even if "#!.exe" is present ! :
> 
> administrator@BM80258908 /c
> $ echo $PATH
> /c/temp:.:/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin:/cygdrive/c/WINNT/system32:/cygdrive/c/WINNT:/cygdrive/c/vim/vim57
> 
> administrator@BM80258908 /c
> $ foo.bat
> 
> c:\>echo test works !
> test works !
> 
> administrator@BM80258908 /c
> $ foo
> bash: foo: command not found
> 
>  I presume that in order to make the three steps of the effect that
> executing just "foo" will work, there is a prerequisite, right ?
> Earnie, what would this prerequisite be ?
> 

The prerequisite is that you have to live by the Win32 rules.  The only
way for the #! suggestion to work is to name the file foo.bat and
execute foo.bat.  All of this quibble over not specifying all of the
filename is just nonsense.  Where in UNIX land do you get filename
extension recognition?  IMO, the executing foo.exe by the name foo is
bogus too as well as the .exe that is put there but if I want to play
with cmd.exe/command.com they have to be.

I don't see that executing foo if the file is named foo.bat exists will
easily work.  It already confuses autoconfiguration with foo.exe
stat'ing as foo.  If we change the routines to find foo.bat as foo then
when we have foo.exe, foo.bat and foo/ in the same directory what does
stat() stat?

My recommendation is to live with it.  Needing to type foo.bat when you
want to execute foo.bat is here to stay.  If you want to be lazy use the
tab-completion routines of the readline library.

Earnie.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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