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 shell to cmd.exe with flag /C on Windows #2713

Merged
merged 1 commit into from
Feb 11, 2020

Conversation

drichardson
Copy link
Contributor

If shell was set to pwsh, then vim-go would fail when creating a new file from a template.

This PR sets the shell to cmd.exe with the /C flag, which is how stock vim on Windows is configured.

Fixes #2712.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 11, 2020

Thank you for the PR. Before merging this, I wonder if there's a way to handle the situation you describe without changing the shell.

Also, we'll need to restore the previous option value once the command is executed if we stick with this approach.

@drichardson
Copy link
Contributor Author

drichardson commented Feb 11, 2020

Thank you for the PR. Before merging this, I wonder if there's a way to handle the situation you describe without changing the shell.

I was wondering the same thing, and I think it would be better (in this case) to execute the command like a unix exec would (not system, aka no shell involved). However, that has a bigger chance of breaking things (and I'm not even sure an exec type facility exists in vimscript). I thought to be safe it would be better to have a consistent shell set for windows (the same way it is done for systems that have /bin/sh).

Also, we'll need to restore the previous option value once the command is executed if we stick with this approach.

That is already done by the finally block below the code I wrote.

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 11, 2020

LGTM

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 11, 2020

I was wondering the same thing, and I think it would be better (in this case) to execute the command like a unix exec would (not system, aka no shell involved). However, that has a bigger chance of breaking things (and I'm not even sure an exec type facility exists in vimscript).

FWIW, I'm not aware of any way to do this with VimL or as an ex command.

But my question was really about wondering what the problem you've experienced is and whether there's a way to avoid changing the shell used by vim-go on Windows.

@bhcleek bhcleek merged commit 5827969 into fatih:master Feb 11, 2020
bhcleek added a commit that referenced this pull request Feb 11, 2020
@drichardson drichardson deleted the fix-2712 branch February 11, 2020 03:03
@bhcleek bhcleek added this to the vim-go 1.23 milestone Feb 11, 2020
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.

go#auto#template_autocreate fails on Windows if shell not cmd.exe
2 participants