>I can't fathom what's going on with rawSystem on your box.  Perhaps the Win98 
>version of command.com has different
quoting semantics, >which don't match what rawSystem is assuming.  I don't 
imagine I'll be able to make much progress on
that, but I'll be happy to incorporate a >fix if you can find one.

Let me see if I get the call-chain correct (System.-prefix omitted):

    Cmd.rawSystem -> Process.runProcess ->
    Process.Internals.runProcessWin32

    Cmd.system -> Process.runCommand ->
    Process.Internals.commandToProcess +
    Process.Internals.runProcessWin32

The first thing I notice is that commandToProcess doesn't do
much (well, now it tries to find a command interpreter, but it does
no translation) - both variants go through runProcessWin32,
which calls Process.Internals.translate! Is that intended?? It
looks like a bug to attempt counter-translation for Cmd.system?

As far as I can see, that means that both system and rawSystem
will create command-lines rich with quotes, and as I mentioned,
command.com will choke on those.

    Prelude> :m System.Process.Internals
    Prelude System.Process.Internals> translate comspec
    "\"C:\\WINDOWS\\COMMAND.COM\""
    Prelude System.Process.Internals> translate "/c"
    "\"/c\""
    Prelude System.Process.Internals> translate "cd"
    "\"cd\""
    Prelude System.Process.Internals> translate "/c cd"
    "\"/c cd\""
    Prelude System.Process.Internals> :m -System.Process.Internals

Here is what happens with rawSystem:

    Prelude> let rs = System.Cmd.rawSystem
    Prelude> comspec <- System.Environment.getEnv "COMSPEC"
    Prelude> comspec
    "C:\\WINDOWS\\COMMAND.COM"
    Prelude> rs comspec ["/c","cd"]
    Angegebenes COMMAND-Verzeichnis ist falsch
    Befehl oder Dateiname nicht gefunden.
    Prelude> rs comspec ["/c cd"]
    Angegebenes COMMAND-Verzeichnis ist falsch
    D:\cygwin\home\unknown
    Prelude>

And here are what I think are the corresponding calls in a
command.com shell - at least they evoke the same reactions:

    C:\Windows>command.com /c "c:\windows\command.com" "/c" "cd"
    Angegebenes COMMAND-Verzeichnis ist falsch
    Befehl oder Dateiname nicht gefunden.

    C:\Windows>command.com /c "c:\windows\command.com" "/c cd"
    Angegebenes COMMAND-Verzeichnis ist falsch
    C:\Windows

If this is correct, any fix would at least involve omitting the quotes
around the parameters if the command-line invokes command.com.

As an experiment, I created my own version of the rawSystem-chain,
replacing the call to translate for the args in runProcessWin32 with
a call to id, and that seems to be sufficient to solve this problem:

    Compiling Main             ( NewCmd.hs, interpreted )
    Ok, modules loaded: Main.
    *Main> rawSystem "command.com" ["/c","cd"]
    D:\cygwin\home\unknown
    *Main> comspec <- System.Environment.getEnv "COMSPEC"
    *Main> rawSystem comspec ["/c","cd"]
    D:\cygwin\home\unknown

    *Main> System.Cmd.rawSystem comspec ["/c","cd"]
    Angegebenes COMMAND-Verzeichnis ist falsch
    Befehl oder Dateiname nicht gefunden.

    *Main> rawSystem comspec ["/c cd"]
    D:\cygwin\home\unknown
    *Main> rawSystem comspec ["/c","echo %PATH%"]
    
c:\Programme\Hugs98;c:\Programme\GreenCard;c:\ghc\ghc-6.4\bin;D:\cygwin\usr\X11r
    
6\bin;c:\texmf\miktex\bin;d:\Software\jdk1.2.1\bin;D:\cygwin\usr\local\bin;D:\cy
    
gwin\bin;D:\cygwin\bin;c:\TEXMF\MIKTEX\BIN;c:\GHC\GHC-6.4\BIN;c:\WINDOWS;c:\WIND
    
OWS;c:\WINDOWS\COMMAND;c:\ADABAS\BIN;c:\PROGRAMME\ERL5.1\BIN;c:\PROGRA~1\ATT\GRA
    PHVIZ\BIN;c:\ADABAS\PGM;c:\PROGRAMME\ERL5.1\BIN;D:\cygwin\usr\X11R6\bin

    *Main> System.Cmd.rawSystem comspec ["/c","echo %PATH%"]
    Angegebenes COMMAND-Verzeichnis ist falsch
    Befehl oder Dateiname nicht gefunden.
    *Main> System.Cmd.rawSystem comspec ["/c echo %PATH%"]
    Angegebenes COMMAND-Verzeichnis ist falsch
    "

whether this creates any other issues I don't know:-)

If you do have command.com somewhere on you system, please
also test Cmd.system with your patch and COMSPEC set to
command.com, as I suspect the quotes introduced in
runProcessWin32 will still cause it to fail?

Btw, the comment for commandToProcess refers to CreateProcess,
and claims that command-line translation is undesirable:

   On Windows, CreateProcess takes a single string for the command,
   which is later decomposed by cmd.exe.  In this case, we just want
   to prepend @\"c:\WINDOWS\CMD.EXE \/c\"@ to our command line.  The
   command-line translation that we normally do for arguments on
   Windows isn't required (or desirable) here.

>We'll definitely do something about the ctrl-C issues before 6.4.1.  No firm 
>release plans yet, but we'll keep you
posted.

Thanks. It would be good to have some working version of 6.4 on
windows, if only to convince maintainers of binary libs (like wxhaskell)
to release updates..

Cheers,
Claus

>
> Btw, I can produce the same effects within COMMAND.COM if I
> put parts of the command line in quotes (don't know whether that
> is a misleading coincidence or a useful hint):
>
> D:\cygwin\home\unknown>command.com /c cd
> D:\cygwin\home\unknown
>
> D:\cygwin\home\unknown>command.com "/c" "cd"
> Angegebenes COMMAND-Verzeichnis ist falsch
> Befehl oder Dateiname nicht gefunden.
>
> D:\cygwin\home\unknown>command.com "/c cd"
> Angegebenes COMMAND-Verzeichnis ist falsch
> D:\cygwin\home\unknown
>
> D:\cygwin\home\unknown>


_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to