[vim/vim] Run command with `:!sudo` fails on gvim after v8.2.2919 (#8951)

34 views
Skip to first unread message

presuku

unread,
Oct 3, 2021, 8:52:55 PM10/3/21
to vim/vim, Subscribed

Describe the bug

sudo command dose not display password prompt, so I can't input password to sudo command on gvim after v8.2.2919 ( 6a43b37 ).

To Reproduce

vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/foobar' -u NONE

Expected behavior
I can input password to sudo command.

Screenshots

  • vim 8.2.2918
    vim-8.2.2918

  • vim 8.2.3469
    vim-8.2.3469

Environment (please complete the following information):

  • Vim 8.2.3469 (8.2.2919 or later)
  • OS: Ubuntu 18.04
  • Terminal: GUI (gtk3)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Dominique Pellé

unread,
Oct 4, 2021, 2:46:44 AM10/4/21
to vim/vim, Subscribed

I cannot reproduce this bug despite using vim-8.2.2969 (gtk3) on xubuntu-18.04.6.
For me, vim asks for the sudo password without error.

presuku

unread,
Oct 4, 2021, 7:42:41 AM10/4/21
to vim/vim, Subscribed

Oops, I forget information about shell, I use zsh.
Would you please try again using the following it ?

SHELL=zsh vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/foobar' -u NONE

And, I also couldn't reproduce this problem when I checked it on bash.
I think this issue is shell matter and original issue (#8314) is same (I also cannot reproduce #8314 on bash).
So, IMO v8.2.2919 should be revert.

Bram Moolenaar

unread,
Oct 5, 2021, 10:01:34 AM10/5/21
to vim/vim, Subscribed


> Oops, I forget information about shell, I use zsh.
> Would you please try again using the following it ?
>
> ```
> SHELL=zsh vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/foobar' -u NONE
> ```

>
> And, I also couldn't reproduce this problem when I checked it on bash.
> I think this issue is shell matter and original issue (#8314) is same (I also cannot reproduce #8314 on bash).
> So, IMO v8.2.2919 should be revert.

That change was made to support zsh. So it looks like we can never get
it right. The problem reported by Felipe Contreras was:

When I launch a background process with gvim and shelltemp and zsh, the spawn process exits immediately and nothing happens:

```sh
SHELL=zsh vim -g -c 'set shelltemp' -c ':!touch /tmp/foobar &'
```

This is a problem when trying to open a browser with `gx` and using `xdg-open` (when it uses `exo-open`), see issue #4738 for more context.

I have no idea what the proper solution is.

--
To be rich is not the end, but only a change of worries.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

presuku

unread,
Oct 6, 2021, 11:21:23 AM10/6/21
to vim/vim, Subscribed

I got it that v8.2.2919 is result of long discussion at #4738 .

I have also investigated the behaviour of other shells (dash and tcsh), so I note the results of it.
I just look this results so I think behaviour of zsh is something wrong... and I don't know why bash is both ok.

  • SHELL=<shell> vim -g -c 'set shelltemp' -c ':!touch /tmp/foobar &' -u NONE

    shell vim v8.2.2918 vim v8.2.2919
    zsh not create file create file
    bash create file create file
    dash create file create file
    tcsh create file create file
  • SHELL=<shell> vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/foobar' -u NONE

    shell vim v8.2.2918 vim v8.2.2919
    zsh can input password can not input password
    bash can input password can input password
    dash can input password can not input password
    tcsh can input password can not input password

anyway, I look for another solution (eg. install askpass or alias gvim="SHELL=bash gvim")
Thank you for reading my broken English.

Bram Moolenaar

unread,
Oct 9, 2021, 9:29:22 AM10/9/21
to vim/vim, Subscribed


> I got it that v8.2.2919 is result of long discussion at #4738 .
>
> I have also investigated the behaviour of other shells (dash and tcsh), so I note the results of it.
> I just look this results so I think behaviour of zsh is something wrong... and I don't know why bash is both ok.
>
> * `SHELL=<shell> vim -g -c 'set shelltemp' -c ':!touch /tmp/foobar &' -u NONE`

>
> |shell|vim v8.2.2918 |vim v8.2.2919|
> |-----|---------------|-------------|

> |zsh |not create file|create file |
> |bash |create file |create file |
> |dash |create file |create file |
> |tcsh |create file |create file |
>
> * `SHELL=<shell> vim -g -c 'set shelltemp' -c ':!sudo touch /tmp/foobar' -u NONE`

>
> |shell|vim v8.2.2918 |vim v8.2.2919 |
> |-----|------------------|----------------------|

> |zsh |can input password|can not input password|
> |bash |can input password|can input password |
> |dash |can input password|can not input password|
> |tcsh |can input password|can not input password|

Thanks for testing. However, using tcsh I can input a password.
I do see the problem with bash, which is more important, since it is
widely used. However, reverting the patch doesn't help.

Perhaps someone can look into why bash doesn't handle "!sudo cmd".

--
hundred-and-one symptoms of being an internet addict:
125. You begin to wonder how often it REALLY is necessary to get up
and shower or bathe.


/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Oct 13, 2021, 5:39:07 AM10/13/21
to vim/vim, Subscribed

should be fixed by fff10d9

Christian Brabandt

unread,
Oct 13, 2021, 5:39:44 AM10/13/21
to vim/vim, Subscribed

I leave this open, as there still seems to be an issue with zsh

presuku

unread,
Oct 13, 2021, 7:08:09 AM10/13/21
to vim/vim, Subscribed

Thank you for accepting my suggestion.

Yee Cheng Chin

unread,
Aug 5, 2022, 11:57:22 PM8/5/22
to vim/vim, Subscribed

I just noticed this change and late to the party. FWIW I am seeing that this does break the :! <cmd> & pattern in the latest MacVim, but it seems to work in gVim in Ubuntu that I tested on, so I think it depends on a variety of factor (probably partially since Vim has a hack of doing signal(SIGHUP, SIG_IGN); to try to support :!xterm &).

It does seem like by making a controlling terminal when you spawn the child process, you are essentially disallowing :! <cmd> & in Vim since when it detaches it will try to kill the processes. I think it's probably ok, if we just say "use :call system('<command> &') instead.

For entering passwords without a controlling terminal, MacVim just sets the SUDO_ASKPASS and SSH_ASKPASS environmental variables to the location of script that prompts for the password in a GUI. This allows sudo to retrieve the password from the external GUI app (since otherwise it needs a proper terminal to read it from). E.g. You can do apt install ssh-askpass in Ubuntu for a simple program to do that.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8951/1207140070@github.com>

Reply all
Reply to author
Forward
0 new messages