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

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

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

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

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