On Friday, February 22, 2013 3:27:41 AM UTC-6, Ingo Karkat wrote:
> Hello Vim developers,
> 
> Sorry for touching that can of worms again, but I've come upon a problem with
> the changed 'shellxquote' option on Windows (patch 7.3.443 (MS-Windows: 'shcf'
> and 'sxq' defaults are not very good) and the few patches following it. Here's
> the discussion as a refresher:
> http://groups.google.com/group/vim_dev/browse_thread/thread/bd53b29c5e5f2a50/be11dca5e9d501bb)
> 
> The problem:
> 
> #v+
> vim -N -u NONE
> :echo system('echo.hi(ho)hi')
> E484: Can't open file D:\temp\VIo408F.tmp
> #v-
> 
> It's the unquoted parentheses in the command. My actual command was
> :echo system('icacls ' . shellescape('C:\foo') . ' /deny
> %userdomain%\%username%:(WD,AD,DC)')
> 
> [SNIP]
> 
> REM Best recommendation is probably to always quote all arguments, even when 
> not
> necessary in a plain shell.
> C:\> C:\Windows\system32\cmd.exe /c (echo.^"hi^(ho^)hi^" ^>D:\temp\VIo8945.tmp
> 2^>^&1)
> #v-
> 
> Therefore, every argument should be quoted; this works:
> :echo system('icacls ' . shellescape('C:\foo') . ' /deny ' .
> shellescape('%userdomain%\%username%:(WD,AD,DC)'))
> 

In other words, if you encounter errors passing arguments to the shell, try
using shellescape, or try escaping things manually with ^. Your original example
is:

  :echo system('echo.hi(ho)hi')

Either of these variants work:

  :echo system('echo.hi^(ho^)hi')
  :echo system('echo.'.shellescape('hi(ho)hi'))

Alternatively, :help 'shellxquote' says that if it is "( then )" is appended.
This gave me a hint, which I tested; this also works:

  :set shellxquote="(
  :echo system('echo.hi(ho)hi')

What are you asking for exactly? A note in the help? Or some further update to
the quoting of shell arguments on Windows? I think a note in the help should
suffice. Where do you think it should go? Maybe we can add a note to E484 that
on Windows it is sometimes caused by unescaped special characters, and to try
using shellescape or a new value of shellxquote to fix it.

Can of worms, indeed! I didn't realize how bad cmd.exe is until that series of 
patches.

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui