Re: [Mingw-users] How can I tell whether my prog is running on cmd.exe or bash?
- Date: Wed, 06 Feb 2008 14:17:37 +0000
- From: Greg Chicares <gchicares@xxxxxxxxxxxxx>
- Subject: Re: [Mingw-users] How can I tell whether my prog is running on cmd.exe or bash?
On 2008-02-06 13:23Z, Paul Leder wrote:
>>> My console code behaves differently when running in a DOS box
[...]
> The problem is that I call 'system' and 'CreateProcess' to spawn child
> processes. These have different requirements for backslashes and quote
> characters depending on what shell they use. I specify the shell myself
> for 'CreateProcess' ('cmd /c' or '/bin/bash -c'), but I still need to
> know which shell to use.
It may be possible to reduce the complexity somewhat, by using
- forward slashes in paths (works with most msw programs)
- CreateProcess() only (it should do whatever system() does)
Quoting would still differ, but maybe you could handle it in
one place instead of two. However...
> You may be thinking that I should just specify 'cmd /c' to
> 'CreateProcess', since it shouldn't matter whether the end-user is
> running in a DOS box or some other shell.
That's exactly what I was about to say. And I believe system()
won't work with a *nix shell because you'll always get "/c"
instead of "-c", and "/bin/sh /c some_command" won't DTRT.
> This may be right, but it's a
> bit more complicated than that. This program is the client half of a
> client-server app, and the remote server will normally be expecting
> Unix-like behaviour on the client. So, at the very least, I need to know
> whether I can support Unix-like behaviour at the client.
If the client is an msw box, then do you have to implement an
equivalent behavior for CMD.EXE? If so, why not use that same
behavior for all msw boxes, even if they happen to have Cygwin
installed?
-------------------------------------------------------------------------
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