Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set shellxquote properly for cmd.exe #3323

Merged
merged 2 commits into from
Jan 19, 2022
Merged

Conversation

nonsleepr
Copy link

I have custom shellxquote in my config and it breaks the plugin. Setting it to quote and restoring after the fact fixes the issue.

@bhcleek
Copy link
Collaborator

bhcleek commented Nov 9, 2021

I'm concerned that this could break others and generally. After reading :help shellxquote, it seems like it would be preferrable for users to set shell rather than vim-go trying to mess with shellquote or shellxquote.

WDYT?

@nonsleepr
Copy link
Author

In my case I have the value of shellxquote changed according to this recommendations and that broke vim-go.
If I understand correctly, that custom handling is to fix #2713, it looks like the fix for just didn't set all the settings for cmd.exe.
An alternative is to remove the change made in #2713 and somehow make shell=pwsh work, but it seems for that shellescape in Vim/Neovim has to be changed. I might be wrong.

@bhcleek
Copy link
Collaborator

bhcleek commented Nov 9, 2021

Ah, I see. In that case, should your changes be modified from

      set shellquote=
      set shellxquote=\"

to

      unset shellquote
      unset shellxquote

so that Vim will do the right thing, relying solely on shell?

@nonsleepr
Copy link
Author

You're right. That's a better idea.

Tested with the following block to reset everything shell-powershell recommends to change and it works alright:

  if go#util#IsWin()
    set shell&
    set shellredir&
    set shellcmdflag&
    set shellpipe&
    set shellquote&
    set shellxquote&
  endif

Would it make sense to do it everywhere, not only on Windows and just rely on defaults to properly escape arguments?

@bhcleek
Copy link
Collaborator

bhcleek commented Nov 10, 2021

I'm a little hesitant to change more than what we know is needed here, because the blast radius covers more systems than I can test on. For now, let's focus only on the shellquote and shellxquote needs that you've identified.

@nonsleepr
Copy link
Author

Makes sense.

Do you think we can add a test global variable which makes the plugin use all defaults?

@bhcleek
Copy link
Collaborator

bhcleek commented Nov 10, 2021

I'm not sure I understand what you mean. Can you clarify?

@nonsleepr
Copy link
Author

I mean, have a global variable, like g:go_use_shell_defaults which, when enabled, sets the following and calls system instead of performing custom handling which is done by s:exec:

set shell&
set shellredir&
set shellcmdflag&
set shellpipe&
set shellquote&
set shellxquote&

@bhcleek
Copy link
Collaborator

bhcleek commented Nov 11, 2021

Thanks for clarifying. I don't think we need to introduce a new option yet.

I'll merge these changes soon.

@bhcleek bhcleek merged commit 2ddd601 into fatih:master Jan 19, 2022
@bhcleek
Copy link
Collaborator

bhcleek commented Jan 19, 2022

Sorry for the long delay; I'd forgotten about this.

bhcleek added a commit that referenced this pull request Jan 19, 2022
@bhcleek bhcleek added this to the vim-go 1.26 milestone Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants