Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Set noshellslash before performing shellescape() #815

Closed
wants to merge 1 commit into from
Closed

Set noshellslash before performing shellescape() #815

wants to merge 1 commit into from

Conversation

arecarn
Copy link

@arecarn arecarn commented Oct 10, 2013

On my end this solves Issue #814 (Errors when using python/python syntax checker). After looking in Vim's help it seems shellescape() effectively does nothing when shellslash is set.

shellescape({string} [, {special}]) shellescape()

Escape {string} for use as a shell command argument.
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}.

Since issue #814 and the effects of shellescape are windows only, I don't think this would effect other systems. I also don't think people depend on shellescape() doing nothing when shellslash is set on windows.

This code basically saves the state of the shellslash option before setting noshellslash. Then it performs the shellescape(). Finally it restores the old state of shellslash.

Save the state of the shell slash option before setting noshellslash.
Then  perform performing shellescape(). Finally restore the old state of
shellslash.

After looking in Vim Help it seems shellescape() effectively does
nothing when shellslash is set.
@lcd047
Copy link
Collaborator

lcd047 commented Oct 10, 2013

Your reading of the help is wrong (the help is ambiguous on that issue). When shellslash is set, shellescape() behaves the same way it does on non-Windows (and non-DOS) systems: it encloses the arguments in single quotes, and replaces all ' with '\''. You can see that it at work in the debug logs posted at #814, and you can also check with the Vim sources. The problem is, backslash is not an escape character for cmd.exe; thus the resulting mess.

Your suggested fix is also wrong: shellescape is essential if you're running an UNIX-like shell. Sorry, but no.

@lcd047 lcd047 closed this Oct 10, 2013
@arecarn
Copy link
Author

arecarn commented Oct 10, 2013

I didn't know that about shellescape() and shellslash On Windows I should have tested a but more ;). I'm not sure if this is a problem though.

shellescape is essential if you're running an UNIX-like shell.

Maybe I phrased my comment incorrectly but. I understand that shellescape is essential for unix like shells, but shellslash isn't. So, what is the the harm in setting noshellslash temporarily? Also my fix doesn't avoid calling shellescape() any more than the current method here.

@lcd047
Copy link
Collaborator

lcd047 commented Oct 10, 2013

So, what is the the harm in setting noshellslash temporarily?

With noshellslash you get the problem opposite to the one you reported: shellescape() breaks UNIX-like shells.

@arecarn
Copy link
Author

arecarn commented Oct 10, 2013

Thank you for your patience, I think I understand now. You are referring to UNIX-like shells on Windows opposed to plain cmd.exe.

@lcd047
Copy link
Collaborator

lcd047 commented Oct 10, 2013

Yes, +shellslash exists only on Windows. The point is, shellslash should be correlated with the shell in effect, otherwise bad things can come from the functions whose behaviours depend on it. That's the kind of fun you can expect from really old code like Vim.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants