This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN
- From: Bill Smith <bsmith at progress dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>, Michel LaBarre <michel dot labarre at rogers dot com>
- Date: Thu, 4 Aug 2016 13:55:28 +0000
- Subject: RE: PATHEXT is fundamental to Windows and Should be recognised by CYGWIN
- Authentication-results: sourceware.org; auth=none
- References: <001001d1edf1$a4e1ae90$eea50bb0$@rogers.com> <1198248887.20160804151307@yandex.ru>
> > Problem 1: Cygwin does not support PATHEXT and really should.
>
> No, it should not. Cygwin is a POSIX environment, and it uses POSIX
> conventions to determine if a file is executable somehow.
>
> > PATHEXT is as fundamental component of Windows program execution as
> PATH.
>
> PATHEXT is a shell (CMD) extension. Some programs do make use of it,
> notable file managers and CMD replacements do, but overall, this is a
> mechanism of finding the file to execute, not of executing it per se.
> You can write your own extension to bash-completion "file-not-found"
> handler, if you so desire.
[Bill Smith]
A couple of years ago I was involved with porting a very large code base of makefiles
& shell scripts to work with Cygwin. In our environment, the main issue was shell scripts calling
*.bat files without the .bat suffix because of the $PATHEXT. The fix was to change
somescript
To
somescript${BAT}
where ${BAT} would be set to .bat on Windows.
Another option available was to create wrapper shell script. So I would create a script named "somescript"
that is only in $PATH on Windows and it would look something like this:
#!/bin/sh
adaptman.bat "$@"
Granted our *.bat files are simple and don't have to worry about arguments with spaces.
> > Problem 2: Cygwin does not support CR-LF delimiters.
>
> Cygwin, in this case, is a library (newlib), and it doesn't care about delimiters.
> This is an application's choice and right to support various EOL's or not.
>
> > For the same reason, it is unfortunate that CYGWIN/bash does not cope
[Bill Smith]
You can tell bash to ignore carriage returns in scripts by doing the following:
set -o igncr
export SHELLOPTS
> > I have been using and developing system software within Unix since
> > 1974 and Windows since the mid-80's. in more recent years (since the
> > mid-90's) I have developed extensive sets of tools (sh/awk/etc..) for
> > corporate and public sector clients - on the order of 100,000 lines of
> > code for representative projects. Most had to run under both Solaris
> > and Windows environments for which I used the MKS toolkit.
>
> And they do run fine, as long as you are not making stupid mistakes, like
> using bogus EOL terminators and expecting the program to work equally on
> different systems.
[Bill Smith]
Agreed. If you need advice on porting scripts to work both in Cygwin and MKS, feel free
to send me email.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple