On Feb 13, 9:41 am, Ben Fritz <[email protected]> wrote: > > See cmd.exe /? > > If /C or /K is specified, then the remainder of the command line after > the switch is processed as a command line, where the following logic > is > used to process quote (") characters: > > 1. If all of the following conditions are met, then quote > characters > on the command line are preserved: > > - no /S switch > - exactly two quote characters > - no special characters between the two quote characters, > where special is one of: &<>()@^| > - there are one or more whitespace characters between the > the two quote characters > - the string between the two quote characters is the name > of an executable file. > 2. Otherwise, old behavior is to see if the first character is > a quote character and if so, strip the leading character and > remove the last quote character on the command line, > preserving > any text after the last quote character.- Hide quoted text - >
It appears that cmd.exe is NOT behaving as documented. Take a look at this: gvim -N -u NONE -i NONE :set shellxquote=\" :set shellcmdflag=/s\ /c :!echo "A&B" The vimrun console pops up: C:\WINDOWS\system32\cmd.exe /s /c "echo "A&B"" A 'B""' is not recognized as an internal or external command, operable program or batch file. shell returned 1 Hit any key to close this window... According to the cmd.exe help, a command with the /s flag given explicitly does NOT fall in the first category. It falls into the second, "otherwise..." category. However, it is being treated as the first category, first executing "echo "A and then executing B"". Experimenting on the cmd.exe window confirms: U:\>cmd /c echo A & pause A Press any key to continue . . . U:\>cmd /c "echo A & pause" A Press any key to continue . . . U:\>cmd /c echo "A & pause" "A & pause" U:\>cmd /s /c echo "A & pause" "A & pause" U:\>cmd /s /c "echo "A & pause"" A 'pause""' is not recognized as an internal or external command, operable program or batch file. Fantastic. I wonder whether the "special characters" text in the cmd.exe help is to blame. Note, this works: :!echo "A^&B" U:\>cmd /s /c "echo "A ^& pause"" "A & pause" (in cmd.exe, the escape character is ^ for some crazy reason or another) Maybe Vim can automatically add this ^ character somehow? This seems like a job for shellescape(). As far as the patch is concerned, I still think it the right thing to do. But we must ask, which is more likely to occur in a call to an external program? The '&' character in an argument, or space characters in the command path and argument? -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
