I think the fundamental problem you are facing is: - cmd.exe (and batch files) parse quoting one way. - where-as programs parse the command line "any-way-they-please", usually (but not always) using some compiler-language specific run-time-library (RTL). (Unix shells are very different: the parsing is done by the shell and the program is provided a pre-parsed argument list).
Erik, One work-around you might try is "call" every command. Since "call" is a built-in in cmd.exe, this should start cmd.exe for every command; thereby running everything (batchfiles and "real" programs) all under a cmd shell. I.e. target: call foo call prog1.bat call prog2.EXE Done this way cmd.exe is consistently used, and you "only" figure out quoting once. I'm most(only) familiar with the microsoft's C RTL, it very much parses quoting differently from cmd.exe batch files. Using a fairly recent ms-CRTL version (different versions have slightly different behavior) I get this: cmd.exe command argv[1] from ms CRTL --------------- -------------------- foo.exe "a b" a b foo.exe "a "b" a b foo.exe "a ""b" a "b foo.exe "a """b" a "b foo.exe "a """"b" a "b foo.exe "a """""b" a ""b foo.exe "a """"":b" a "":b foo.exe "a """"""b" a ""b foo.exe "a """""""b" a ""b foo.exe "a """"""""b" a """b foo.exe "a \" b" a " b Note in the last example above, a batchfile would see TWO arguments (not one). 1st: "a \" 2nd: b" .dfc. From: make-w32-bounces+dcampbell=nvidia....@gnu.org [mailto:make-w32-bounces+dcampbell=nvidia....@gnu.org] On Behalf Of Erik Carstensen Sent: 2013-05-03 Friday 08:17 To: make-w32@gnu.org Subject: Incorrect quoting of """" """" in master branch, with SHELL=cmd.exe When passing """" """" to a shell, it is evaluated to a single word " " if cmd.exe evaluates it, but to an unquoted single space if make short-circuits the cmd.exe argument. Test case: foo.mk<http://foo.mk> contains: SHELL=cmd.exe $(info x is $(x)) default: mkdir $(x) Makefile contains: SHELL=cmd.exe default: $(MAKE) -f foo.mk<http://foo.mk> x=a"""" """"b With 3.82 (which lets cmd.exe handle the quotes), this yields: x is a" "b With master (which short-circuits it), it yields: x is a *** No rule to build target 'b'. Stop. My actual use case is similar to the 'mkdir' invocation in foo.mk<http://foo.mk> (a file with spaces needs to be quoted twice in order to be passed to commands in a recursive make). I have found sufficient workarounds for my use cases.
_______________________________________________ Make-w32 mailing list Make-w32@gnu.org https://lists.gnu.org/mailman/listinfo/make-w32