|
From: | Duane Campbell |
Subject: | RE: Incorrect quoting of """" """" in master branch, with SHELL=cmd.exe |
Date: | Fri, 3 May 2013 11:39:19 -0700 |
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: address@hidden [mailto:address@hidden On Behalf Of Erik Carstensen 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 contains: SHELL=cmd.exe $(info x is $(x)) default: mkdir $(x) Makefile contains: SHELL=cmd.exe default: $(MAKE) -f 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 (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. |
[Prev in Thread] | Current Thread | [Next in Thread] |