using shellslash on windows.

403 views
Skip to first unread message

mattn

unread,
Nov 10, 2010, 6:58:38 AM11/10/10
to vim_dev, br...@vim.org, vim...@vim.org
Hi list.

I'm having this issue for long time.
I want to use shellshash on windows. Because some GNU's win32
utilities are not work correctly with including backslash in the path.
And I remember: that Vim was working cheerfully with set shellslash on
windows.
Perhaps become at version 7.0, I couldn't use shellshash on windows on
a sudden.

if set shellslash, "shellescape()" quote the arguments with single
quote.

The arguments for external command became to quote as single quote.
i.e., I lost the way to use shellslash for passing double quoted
arguments.
To make matters worse, I get an error with doing following.

:e http://www.google.com/
:!curl 'http://www.google.com/' -o 'C:/DOCUME~1/MATTN/Temp/
VIA2046.tmp'
curl: (1) Unsupported protocol: 'http

And I'll look that buffer name will be following.

http:\\www.google.com\

Few months ago, I posted few suggestion about fixing this problem. But
it was not solved.
I tried to change to use noshellshash in my vimrc repeatedly. but I
couldn't be love it.

So I want to suggest to fix this again.

By and large, most user is using cmd.exe (or command.com) on windows.
This is meaning that Vim should escape double quote to pass the
arguments for command.
However, currently Vim interpret shellslash option against whether
should use single or double quote.
This is not right. This should be checked whether a 'shell' option
contain 'sh'. (same as shellxquote option)

Please check this patch.

- Yasuhiro Matsumoto

diff -r 1ccc1ace9e5b src/misc2.c
--- a/src/misc2.c Wed Nov 03 22:32:24 2010 +0100
+++ b/src/misc2.c Wed Nov 10 20:54:26 2010 +0900
@@ -1359,6 +1359,9 @@
char_u *escaped_string;
int l;
int csh_like;
+# if defined(WIN32) || defined(WIN16) || defined(DOS)
+ int using_command_prompt = !p_ssl || *p_sxq == NUL;
+# endif

/* Only csh and similar shells expand '!' within single quotes.
For sh and
* the like we must not put a backslash before it, it will be
taken
@@ -1371,7 +1374,7 @@
for (p = string; *p != NUL; mb_ptr_adv(p))
{
# if defined(WIN32) || defined(WIN16) || defined(DOS)
- if (!p_ssl)
+ if (using_command_prompt)
{
if (*p == '"')
++length; /* " -> "" */
@@ -1401,7 +1404,7 @@

/* add opening quote */
# if defined(WIN32) || defined(WIN16) || defined(DOS)
- if (!p_ssl)
+ if (using_command_prompt)
*d++ = '"';
else
# endif
@@ -1410,7 +1413,7 @@
for (p = string; *p != NUL; )
{
# if defined(WIN32) || defined(WIN16) || defined(DOS)
- if (!p_ssl)
+ if (using_command_prompt)
{
if (*p == '"')
{
@@ -1452,7 +1455,7 @@

/* add terminating quote and finish with a NUL */
# if defined(WIN32) || defined(WIN16) || defined(DOS)
- if (!p_ssl)
+ if (using_command_prompt)
*d++ = '"';
else
# endif

Bram Moolenaar

unread,
Nov 10, 2010, 9:07:39 AM11/10/10
to mattn, vim_dev

Yasuhiro Matsumoto wrote:

'shellslash' assumes that you are using a Unix-like shell. I don't see
how you can set 'shellslash' and use cmd.exe, many external commands
that use Windows commands or are handled by the shell will fail,
since all / in the argument are seen as flags.

Having the behavior depend on 'shellxquote' makes this more complicated,
I'm not sure if that is a good idea. It's hard to think of all the
possible combinations of commands (both shell and others) and what
arguments they take.

So why don't you use a Unix-like shell?

--
BRIDGEKEEPER: What is your favorite editor?
GAWAIN: Emacs ... No, Viiiiiiiiiiimmmmmmm!
"Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

mattn

unread,
Nov 10, 2010, 11:57:37 AM11/10/10
to vim_dev

On Nov 10, 11:07 pm, Bram Moolenaar <B...@Moolenaar.net> wrote:
> Yasuhiro Matsumoto wrote:
> > I'm having this issue for long time.
> > I want to use shellshash on windows. Because some GNU's win32
> > utilities are not work correctly with including backslash in the path.
> > And I remember: that Vim was working cheerfully with set shellslash on
> > windows.
> > Perhaps become at version 7.0, I couldn't use shellshash on windows on
> > a sudden.
>
> >    if set shellslash, "shellescape()" quote the arguments with single
> > quote.
>
> > The arguments for external command became to quote as single quote.
> > i.e., I lost the way to use shellslash for passing double quoted
> > arguments.
> > To make matters worse, I get an error with doing following.
>
> >   :ehttp://www.google.com/
This answer is:

* Vim was working good with shellslash on windows.
* Broken URL is shown in status line.
* I have to provide vimscripts for any users. (user of cmd.exe also)

I want to hear from you:

* Why don't you fix this problem?
* Why do you trancate shellslash from us?

- Yasuhiro Matsumoto

mattn

unread,
Nov 10, 2010, 12:00:39 PM11/10/10
to vim_dev
:s/truncate/abandone/

Bram Moolenaar

unread,
Nov 10, 2010, 12:56:43 PM11/10/10
to mattn, vim_dev

Yasuhiro Matsumoto wrote:


You didn't answer my question about why you don't use a Unix-like shell
while you do set 'shellslash'. That was the original purpose of this
option, you appear to be in a different situation. So why do you set
'shellslash' even though you are using cmd.exe? You use some Unix-like
utilities but not a Unix-like shell, that's a strange situation.

I don't like adding a side effect to the 'shellxquote' option. I'm not
sure there will be situations where 'shellxquote' is set or unset where
it should not have an effect on quoting in other places.

--
It is illegal for anyone to try and stop a child from playfully jumping over
puddles of water.
[real standing law in California, United States of America]

Ben Fritz

unread,
Nov 10, 2010, 3:11:20 PM11/10/10
to vim_dev


On Nov 10, 8:07 am, Bram Moolenaar <B...@Moolenaar.net> wrote:
>
> 'shellslash' assumes that you are using a Unix-like shell.  I don't see
> how you can set 'shellslash' and use cmd.exe, many external commands
> that use Windows commands or are handled by the shell will fail,
> since all / in the argument are seen as flags.
>

cmd.exe handles forward-slash path separators for many commands these
days (although tab-completion only works with backslash).

I have shellslash set in my .vimrc mainly so I almost never need to
worry about escaping the \ path separators within Vim. Every now and
then I need to temporarily turn it off, but usually in predefined
commands (like my CScope wrappers, for example).

I do load it as follows, I don't recall the exact issues this works
around:

" use forward slashes on Windows, but wait until after everything is
loaded to
" not screw stuff up
if has('autocmd')
autocmd VimEnter * set shellslash
endif


Note, that the :help does not specify that 'shellslash' should *only*
be used on Unix-like shells, only that it is *useful* on Unix-like
shells. Some people (like me) also find it useful on cmd.exe, but have
encountered some problems.

I would certainly like it if shellescape() depended only on the value
of 'shell' and not on the value of 'shellslash'. But it is easy enough
to work around. Maybe just a mention in :help 'shellslash' of the
other behaviours it affects would be enough.

mattn

unread,
Nov 10, 2010, 7:52:35 PM11/10/10
to vim_dev
Unix-like-Shell has problem also.
Most of Unix-like-Shell don't accept multi-byte-characters correctly.
And some of them should use "/c/progra~1/" to access to "c:\Program
Files\".
or "/cygdrive/c/progra~1/".
This make another problem. Thus I don't use unix-like-shell.

> I don't like adding a side effect to the 'shellxquote' option.  I'm not
> sure there will be situations where 'shellxquote' is set or unset where
> it should not have an effect on quoting in other places.

Then, how about new option to control behavior of shellescape() ?
Fundamentally, This problem based on that:
Behavior of shellescape() depend on shellslash.

I think that this stay out of settings of shellslash.

Or, new option for use slash for path, for example 'pathslash'.
It is similar to shellslash. but not quote to single quote.

- Yasuhiro Matsumoto

mattn

unread,
Nov 15, 2010, 10:00:14 AM11/15/10
to vim_dev
Bram, I'm looking for your reply.
As Ben's said, cmd.exe can treat slash as path separator.

- Yasuhiro Matsumoto

James Vega

unread,
Nov 15, 2010, 10:15:44 AM11/15/10
to vim...@googlegroups.com
On Mon, Nov 15, 2010 at 10:00 AM, mattn <matt...@gmail.com> wrote:
> Bram, I'm looking for your reply.
> As Ben's said, cmd.exe can treat slash as path separator.

That depends on the command that's being run. There are still commands
which don't handle / as a path separator properly.

--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>

mattn

unread,
Nov 15, 2010, 10:56:08 AM11/15/10
to vim_dev


On Nov 16, 12:15 am, James Vega <james...@jamessan.com> wrote:
> On Mon, Nov 15, 2010 at 10:00 AM, mattn <mattn...@gmail.com> wrote:
> > Bram, I'm looking for your reply.
> > As Ben's said, cmd.exe can treat slash as path separator.
>
> That depends on the command that's being run.  There are still commands
> which don't handle / as a path separator properly.

If you use shell as unix-like-shell, this will be same result. unix-
like-shell don't replace arguments from backslash to slash cleverly.
Most users of shellslash know the way to escape the problems.
And they hope: The merit of 'possible to use slash' is bigger than
demerit of 'some commands don't handle slash as a path separator' (I
guess)

Thanks.

Ben Fritz

unread,
Nov 15, 2010, 4:09:29 PM11/15/10
to vim_dev


On Nov 15, 9:15 am, James Vega <james...@jamessan.com> wrote:
> On Mon, Nov 15, 2010 at 10:00 AM, mattn <mattn...@gmail.com> wrote:
> > Bram, I'm looking for your reply.
> > As Ben's said, cmd.exe can treat slash as path separator.
>
> That depends on the command that's being run.  There are still commands
> which don't handle / as a path separator properly.
>

Yes, but many commands do handle it. I would never support making
'shellslash' set by default and it's one of the first things I look at
if I'm having problems with external commands, but I think that
breaking shellescape() and other features when it is set is the wrong
thing to do. 'shellslash' can be useful without a Unix-like shell.

Bram Moolenaar

unread,
Nov 16, 2010, 7:07:34 AM11/16/10
to mattn, vim_dev

Yasuhiro Matsumoto wrote:

[...]

It's in the todo list. So for none of the alternatives stand out as a
nice solution.

--
Living on Earth includes an annual free trip around the Sun.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\

\\\ an exciting new programming language -- http://www.Zimbu.org ///

Reply all
Reply to author
Forward
0 new messages