Web lists-archives.org

Re: [Mingw-users] How can I tell whether my prog is running on cmd.exe or bash?




On Thursday 07 February 2008 22:55, Paul Leder wrote:
> I have to confess that I didn't know that there were any other Unixy
> shells on Windows (I haven't looked at MSYS). Besides, I've worked in
> the industry I'm writing this app for for ~20 years, and I've never
> heard of anyone using anything other than Cygwin or plain DOS.

Then you need to remove your blinkers, and broaden your horizons.  Let's 
see; just off the top of my head: for MS-DOS, there were 4DOS, DJGPP 
and the proprietary MKS Toolkit, all of which replaced command.com; the 
latter two provided Unixy shells.  On Woe32, besides Cygwin, there is 
Microsnot's own SFU, (a.k.a. Interix), MSYS, AT&T's UWIN, DJGPP and MKS 
again, and also several native ports of various Unix shells; there is 
also the non-Unixy 4NT, as an alternative to cmd.exe.

> Just parsing PATH is useless to me. I could look for a
> host of shells in all locations in PATH,

You don't have to parse the PATH; spawnlp or spawnvp will take care of 
that for you...

> but (1) if it's a Cygwin PATH then it's no use because it won't make
> sense to 'CreateProcess' 

You don't tell spawnlp or spawnvp what the PATH is; they get it for 
themselves, from the environment, and they shouldn't ever see a Cygwin 
PATH, in a native executable, so...

> until it's been through 'cygpath -m' anyway,

is completely irrelevant.  (Oh yes, because you won't use GPL code, you 
have to fix the quoting bug for yourself, of course, but provided you 
understand the issues, that really isn't difficult).

> and (2) the 'shell' may turn out to be a completely irrelevant
> Windows program called, for example, ksh.exe.

Huh?  Any program called ksh.exe *should* be a Korn shell; that is more 
than capable of handling any Bourne shell commands you pass to it, and 
if it isn't a Korn shell, then the user who installed it *deserves* all 
the grief which ensues.  Same goes for bash.exe, pdksh.exe or zsh.exe.  
The only likely rogues would be csh.exe or tcsh.exe, since they don't 
promise Bourne shell compatibility.

> In short, I can't take the risk of executing some arbitrary Windows
> program just because it has the right name and happens to be on the
> path. Either it's /bin/sh, or nothing.

Yet you started out by asking about bash, which you now reject.  You 
also reject ash, (which is what Cygwin's sh.exe *really* is).  In fact, 
what guarantee do you have that even sh.exe is a kosher Unix shell?

Just my two pennies.  I really couldn't care less what you do; I shall 
not be using your software.  The code in the exec wrappers works fine 
for me, and for the Woe32 port of GNU troff, in the MinGW port of man, 
and probably in other projects, of which I am unaware.

Regards,
Keith.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users