Skip to content
New issue

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

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

Already on GitHub? # to your account

Doesn't work when using SHELL=/bin/tcsh #159

Closed
arp242 opened this issue Feb 6, 2015 · 15 comments
Closed

Doesn't work when using SHELL=/bin/tcsh #159

arp242 opened this issue Feb 6, 2015 · 15 comments

Comments

@arp242
Copy link

arp242 commented Feb 6, 2015

This is, presumably, the same issue as with the fish shell: #12 , some people also reported problems with zsh as well...

IMHO, the proposed workaround is not a very good one. If I use set shell=/bin/sh in my vimrc, all my :!cmd filters now use /bin/sh instead of tcsh; so I lose the tcsh semantics I'm used to, including my aliases that I use in tcsh. I could set this manually before every vim-plug command (which is what I do now), but this is obviously rather awkward.

Can't vim-plug set the shell to /bin/sh when running shell commands (and re-set it to whatever it was) on completion? Or use some other method that doesn't require globally setting the shell in Vim (such as maybe system('/bin/sh -c cmd')...

Thanks :-)

@junegunn
Copy link
Owner

junegunn commented Feb 7, 2015

Thanks for the report. Could you test if the above patch fixes your problem?

https://raw.githubusercontent.com/junegunn/vim-plug/fix-159/plug.vim

@arp242
Copy link
Author

arp242 commented Feb 7, 2015

Thanks :-) I tried all the commands, and everything seems to work fine.

A related issue (minor) I noticed:

If I use :PlugSnapshot, it will create a script with #!/bin/bash; however, my system (FreeBSD) doesn't have a /bin/bash, as bash is installed to /usr/local/bin/bash...

As far as I can see, there's no bash-specific syntax being used? So #!/bin/sh would also suffice? Otherwise using #!/usr/bin/env bash is considered to be "better", since that uses PATH to lookup the bash executable...

@junegunn
Copy link
Owner

junegunn commented Feb 7, 2015

Good point, thanks!

junegunn added a commit that referenced this issue Feb 7, 2015
Fix #159 - Avoid errors on tcsh and fish
@junegunn
Copy link
Owner

junegunn commented Feb 7, 2015

The fixes are now merged to master. Thanks.

@vhda
Copy link

vhda commented May 14, 2015

I'd like to reopen this issue.

The implemented fix is not correct because shellredir is not updated to match the shell setting.
Looking at :help shellredir the following is described:

For Unix, if the 'shell' option is "csh", "tcsh" or "zsh" during initializations,
the default becomes ">&".  If the 'shell' option is "sh", "ksh" or "bash" the
default becomes ">%s 2>&1".

So, if vim is started in a tcsh the shell redirection used in system() calls will not work properly.
To overcome this, a temporary shellredir must be set as following:

set shellredir=>%s\ 2>&1

@junegunn
Copy link
Owner

@vhda I see, but does it make vim-plug fail? I tried with set shell=/bin/tcsh shellredir=>& and everything works just as expected. When do you get errors?

@vhda
Copy link

vhda commented May 14, 2015

I detected the issue exactly because I was trying to call :PlugUpdate and :PlugUpgrade. Any of these commands will fail due to vim being unable to redirect the output of system() into a temporary file.
I don't understand why that fails to happen using the settings you described. Could I ask you to to try to call :PlugUpgrade from a vim started inside a tcsh?

@vhda
Copy link

vhda commented May 14, 2015

@junegunn forgot one very important detail: I use dash in Debian. As such, when vim-plug sets shell to /bin/sh it will be in fact using /bin/dash. This POSIX compliant shell does not understand the >& redirection, which is a bashism.

@starcraftman
Copy link
Contributor

@vhda I can't replicate either. Seems to work fine.

Don't think last detail matters. Ubuntu also has/bin/sh => /bin/dash. Issues would flood in if that was related.

To test, all I did was invoke tcsh then start vim & PlugUpdate. You are saying this procedure should fail?

Side Note: When you say you use dash, you mean as your terminal for daily commands right? I'm curious, why?

@vhda
Copy link

vhda commented May 14, 2015

No, I use tcsh as my command shell. dash is only used as the default shell of the system.

I am also unable to replicate this in my Debian unstable at home, so I'll need to debug this further at work tomorrow. Will add more information as soon as I have any.

@arp242
Copy link
Author

arp242 commented May 14, 2015

I've been using vim-plug with tcsh as my login shell since the issue was fixed in February; haven't experienced any problems with either :PlugUpgrade or :PlugUpdate.

I believe vim-plug tries to use Ruby, Python, or a VimScript fallback depending on which features are available. My Vim has both +ruby and +python, so perhaps this problem only occurs when using Python or the VimScript fallback?

@junegunn
Copy link
Owner

@vhda Well, it's strange, but anyway, the following patch will set shellredir as you initially suggested. Does it help?

https://gist.github.com/junegunn/3d8a435a660df20b164b

@vhda
Copy link

vhda commented May 15, 2015

@junegunn your patch fixes the problem.

Debug information: my vim installation has +ruby, +python and -python3. My default shell is tcsh and /bin/sh points to dash (version 0.5.7-4+b1). Using :PlugUpgrade to understand that two temporary files are created:

  1. One in vim-plug, line1789.
  2. Another created automatically by vim's system() call.

The error I have is in the second temporary file and the error message is the following:

Error detected while processing function <SNR>5_upgrade..<SNR>5_system:
line    7:
E484: Can't open file /tmp/vOXZBJD/1

I still was not able to find any culprit other than shellredir.

junegunn added a commit that referenced this issue May 15, 2015
@junegunn
Copy link
Owner

@vhda Okay, I was able to reproduce the error on OS X by

  • Changing /bin/sh (which was actually bash) to dash
  • and setting the default shell to /bin/tcsh

And confirmed that changing shellredir fixes the issue. The patch is merged to master. Thanks.

@vhda
Copy link

vhda commented May 15, 2015

@junegunn finally! I was starting to believe I had something wrong on my system! :)
It's working perfectly for me now. Thanks a lot for the fix.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants