Re: [Mingw-users] How can I tell whether my prog is running on cmd.exe or bash?
- Date: Sat, 9 Feb 2008 23:17:10 +0000
- From: Keith Marshall <keithmarshall@xxxxxxxxxxxxxxxxxxxxx>
- Subject: Re: [Mingw-users] How can I tell whether my prog is running on cmd.exe or bash?
On Saturday 09 February 2008 18:09, Paul Leder wrote:
> But, if Cygwin isn't in the path, and there's no
> reason that it should be, then it's pointless for me, or any program,
> to parse the path looking for a list of shells.
What absolute rubbish! The *native* port of man, for MinGW, wants a
Unixy shell to run the troff pipeline. It gets that by searching the
PATH, (internally, within a spawnlp call), and it *doesn't* require
Cygwin to be the provider; it works perfectly well with any Unix shell
it finds.
> In *Windows*?? I pick up PATH, on a Windows machine, search the
> entries, and find a program called ksh.exe? Surely it's not exactly
> prudent to execute that program, in the hope that it's a Korn shell?
Why not? At least two of the toolkits I mentioned yesterday provide
Korn shells, (one of them being the commercially produced MKS Toolkit),
so I would have no qualms about assuming that ksh.exe is *exactly* what
it appears to be -- a fully functional Korn shell.
> *Thats* why 'cygpath' is so useful. If cygpath understands /bin/sh,
Why bother with cygpath at all? If...
spawnlp( _P_WAIT, "sh", "sh", "-c", "'command to execute'", NULL );
(or the equivalent invoked directly by CreateProcess), executes as you
expect, doesn't that give you sufficient confidence that the `sh' you
found is satisfactory? That removes the added overhead of the cygpath
fork, *and* removes the explicit Cygwin dependency.
> then I can be almost ceratin that the return value is a proper shell.
Is it any more prudent to assume that cygpath.exe is what you think it
should be, than to assume that ksh.exe is a Korn shell? It could just
as well be a trojan, which will wipe your hard drive. You have to
trust your users to adopt a sensible attitude to software installation;
users who have *any* sort of Unix emulation software installed will
DTRT here; those who don't are extremely unlikely to have anything
named as a Unix shell, which isn't just that.
But, who cares anyway? You are happy with your solution; I am happy
with mine. Further discussion would seem pointless.
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