make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make CVS (Win32) improperly leaves batch files with -n


From: J. David Bryan
Subject: Re: Make CVS (Win32) improperly leaves batch files with -n
Date: Fri, 17 Feb 2006 11:35:31 -0500

On 16 Feb 2006 at 22:43, Eli Zaretskii wrote:

> Here's an example.  Let's assume that the rule's command says this:
> 
> all:
>    cd "c:\\foo bar" && frobnicate baz
> 
> (The double \\ is because Make requires that.)  Now, to run this
> directly through "cmd /c", we need to quote the command, i.e. invoke
> CMD like so:
> 
>   cmd /c "cd "c:\\foo bar" && frobnicate baz"
> 
> But this will not work unless we quote or escape the inner quotes and
> the special character &.

Thank you for the explanation.  However, it appears that cmd.exe actually 
doesn't mind the extra quotes.  I tried this from cmd.exe under both NT 4.0 
and XP:

  mkdir "b c"
  echo Hello from subdir > "b c\msg.txt"
  cmd /c "cd "b c" && type msg.txt"

...and "Hello from subdir" appeared.  I've found an explanation for this 
behavior in a Microsoft KB article:

  http://support.microsoft.com/?kbid=191495

(See the section titled "MORE INFORMATION" for the quoting rules.)

Then I wrote a small test program that called CreateProcess to test the 
above.  The call began with:

    CreateProcess ("C:\\winnt\\system32\\cmd.exe",
                   "\"/c cd \"b c\" && type msg.txt\"",
                   ... )

...so we're passing "/c cd "b c" && type msg.txt" (with enclosing quotes) 
to cmd.exe, and that printed the text.  I also tried passing the string 
without the enclosing quotes:

    CreateProcess ("C:\\winnt\\system32\\cmd.exe",
                   "/c cd \"b c\" && type msg.txt",
                   ... )

...and that worked fine too.


> By contrast, invoking this command via a batch file boils down to
> writing the rule's command verbatim to the batch files, and then
> invoking a simple command.... 

My initial tests seem to indicate, though, that the command that would be 
written to the batch file could be passed directly to cmd.exe instead, 
without alteration.  So, unless there's some pathological case that I'm not 
grasping, batch files could be bypassed, and the shell could be invoked 
directly for cmd.exe.

I'll investigate a patch for this, if you think that it's a reasonable 
change.


> Did I succeed to explain the problem?

Your explanation was appreciated.

                                      -- Dave





reply via email to

[Prev in Thread] Current Thread [Next in Thread]