Loading ...
Sorry, an error occurred while loading the content.

shellescape() doesn't work in Windows with 'shellslash' set

Expand Messages
  • Benjamin Fritz
    Since Windows cmd.exe handles forward slash perfectly well, and things like wildcards in file names do NOT work with backslashes, I have shellslash set in
    Message 1 of 1 , Dec 1, 2009
    • 0 Attachment
      Since Windows' cmd.exe handles forward slash perfectly well, and
      things like wildcards in file names do NOT work with backslashes, I
      have 'shellslash' set in my _vimrc in Windows. I have recently ran
      into the following problem:

      Launch Vim in Windows XP with:

      gvim -N -u NONE -i NONE

      :echo shellescape('C:/Program Files/Vim')
      -> "C:/Program Files/Vim"

      :set shellslash
      :echo shellescape('C:/Program Files/Vim')
      -> 'C:/Program Files/Vim'

      The latter obviously will NOT work in cmd.exe.

      It looks like this is intentional behavior. From :help shellescape() :

      On MS-Windows and MS-DOS, when 'shellslash' is not set, it
      will enclose {string} in double quotes and double all double
      quotes within {string}.
      For other systems, it will enclose {string} in single quotes
      and replace all "'" with "'\''".

      This does not make any sense to me. Presumably, this is an attempt to
      allow shellescape to work as expected on *nix-style shells running on
      Windows, but isn't the 'shell' option better to use than 'shellslash'?
      Other options such as 'shellxquote' depend on 'shell' rather that
      'shellslash'.

      Does anyone know the reasoning behind the shellescape behavior? Is
      there any situation where using 'shell' instead of 'shellslash' would
      NOT be better?

      I can work around this by saving, resetting, and restoring the value
      of shellslash around any command using shellescape, but I'm worried
      about plugin behavior, etc., and it's quite a hassle.

      --
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.