[vim/vim] Running :make does not set v:shell_error (#5994)

14 views
Skip to first unread message

George Brown

unread,
Apr 26, 2020, 7:23:41 AM4/26/20
to vim/vim, Subscribed

Describe the bug
:make does not appear to set v:shell_error as other external commands do.

To Reproduce

$ cat test.vim 
set makeprg=exit\ 1
silent make
call assert_equal(1, v:shell_error)

set formatprg=exit\ 1
normal! gqip
call assert_equal(1, v:shell_error)

set equalprg=exit\ 1
normal! ==
call assert_equal(1, v:shell_error)

silent !exit 1
call assert_equal(1, v:shell_error)

echo v:errors

$ vim --clean -S test.vim

['/private/tmp/test.vim line 3: Expected 1 but got 0']

Expected behavior
I would expect the exit code of whatever makeprg returns when invoked via :make to set v:shell_error accordingly.

Environment (please complete the following information):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 26 2020 11:57:03)
macOS version
Included patches: 1-640
Compiled by gbr...@lappy.local
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
+arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      +mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        +termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
+balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            +gettext           +netbeans_intg     +termresponse
++builtin_terms    -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              -perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     +keymap            +postscript        +vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      +langmap           +profile           +virtualedit
+comments          +libcall           -python            +visual
+conceal           +linebreak         -python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
-cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          +rightleft         +wildignore
+cursorshape       -lua               -ruby              +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
+emacs_tags        +mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      +mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/Users/gbrown/local/vim/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -lintl -framework AppKit  
  • OS: macOS 10.15.4
  • Terminal: Terminal.app


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Apr 26, 2020, 10:37:47 AM4/26/20
to vim/vim, Subscribed

Works fine for me. What is the command that actually gets executed?
It should be something like ":!exit 1 |& tee /tmp/vt42YzR/6"
Perhaps your "tee" command does not pass on the exit value

George Brown

unread,
Apr 26, 2020, 11:00:47 AM4/26/20
to vim/vim, Subscribed

Works fine for me. What is the command that actually gets executed?
It should be something like ":!exit 1 |& tee /tmp/vt42YzR/6"

It is indeed.

Perhaps your "tee" command does not pass on the exit value

I'm not sure what's meant by this? So far as I'm aware the only way to do this is with something like bash's set -o pipefail. I've tried doing using this and I v:shell_error is still 0 for me.

Bram Moolenaar

unread,
Apr 26, 2020, 12:13:10 PM4/26/20
to vim/vim, Subscribed


> > Works fine for me. What is the command that actually gets executed?
> > It should be something like ":!exit 1 |& tee /tmp/vt42YzR/6"
>
> It is indeed.
>
> > Perhaps your "tee" command does not pass on the exit value
>
> I'm not sure what's meant by this? So far as I'm aware the only way to
> do this is with something like bash's `set -o pipefail`. I've tried

> doing using this and I `v:shell_error` is still 0 for me.

Ah, my 'shell' was set to /bin/tcsh. Then it works. With bash it
doesn't work. I don't think we can fix this in Vim, we just don't get
the exit value.

--
hundred-and-one symptoms of being an internet addict:
25. You believe nothing looks sexier than a man in boxer shorts illuminated
only by a 17" inch svga monitor.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Gary Johnson

unread,
Apr 26, 2020, 1:22:45 PM4/26/20
to reply+ACY5DGH6N7WNKH2ZZ7...@reply.github.com, vim...@googlegroups.com
On 2020-04-26, Bram Moolenaar wrote:
>
> > > Works fine for me. What is the command that actually gets executed?
> > > It should be something like ":!exit 1 |& tee /tmp/vt42YzR/6"
> >
> > It is indeed.
> >
> > > Perhaps your "tee" command does not pass on the exit value
> >
> > I'm not sure what's meant by this? So far as I'm aware the only way to
> > do this is with something like bash's `set -o pipefail`. I've tried
> > doing using this and I `v:shell_error` is still 0 for me.
>
> Ah, my 'shell' was set to /bin/tcsh. Then it works. With bash it
> doesn't work. I don't think we can fix this in Vim, we just don't get
> the exit value.

I had this problem a while back and solved it with this setting:

:let &shellpipe .= " %s; exit ${PIPESTATUS[0]}"

I just tested it again and it seems to work with Vim 8.2.587 and
Bash 4.3.48(1) on Ubuntu 16.04.

HTH,
Gary

vim-dev ML

unread,
Apr 26, 2020, 1:23:06 PM4/26/20
to vim/vim, vim-dev ML, Your activity

George Brown

unread,
Apr 26, 2020, 3:36:56 PM4/26/20
to vim/vim, vim-dev ML, Comment

I've made things by tweaking shellpipe and makeef along with a bit of scripting.

When opening this I wanted my initial report to be high level. But getting into the implementation does Vim have to rely on tee? I.E. when invoking :make could Vim not read and print the errorfile itself? This would avoid relying on shell features (which may not be portable).

This may also alleviate the need to include a copy of tee in Vim's source for Windows systems.


You are receiving this because you commented.

Gary Johnson

unread,
Apr 26, 2020, 4:11:14 PM4/26/20
to reply+ACY5DGA7LWTBHW3PXL...@reply.github.com, vim...@googlegroups.com
On 2020-04-26, George Brown wrote:
> I've made things by tweaking shellpipe and makeef along with a bit of
> scripting.
>
> When opening this I wanted my initial report to be high level. But getting into
> the implementation does Vim have to rely on tee? I.E. when invoking :make could
> Vim not read and print the errorfile itself? This would avoid relying on shell
> features (which may not be portable).
>
> This may also alleviate the need to include a copy of tee in Vim's source for
> Windows systems.

Tee is used only on Unix. On Windows, 'shellpipe' is

>%s 2>&1

See ":help 'shellpipe'". As you can see, Vim sets 'shellpipe'
according to the type of system it is on. If none of those settings
match your needs, you can set 'shellpipe' as you wish and/or submit
a patch if you think that Vim can reliably detect the situation and
that the problem affects others.

Regards,
Gary

vim-dev ML

unread,
Apr 26, 2020, 4:11:33 PM4/26/20
to vim/vim, vim-dev ML, Your activity

George Brown

unread,
Apr 26, 2020, 4:19:56 PM4/26/20
to vim/vim, vim-dev ML, Comment

Closed #5994.


You are receiving this because you commented.

George Brown

unread,
Apr 26, 2020, 4:19:57 PM4/26/20
to vim/vim, vim-dev ML, Comment

Closing this as I've made things work for me.


You are receiving this because you commented.

Bram Moolenaar

unread,
Apr 26, 2020, 4:34:57 PM4/26/20
to vim...@googlegroups.com, George Brown


> I've made things by tweaking `shellpipe` and `makeef` along with a bit
> of scripting.
>
> When opening this I wanted my initial report to be high level. But
> getting into the implementation does Vim have to rely on `tee`? I.E.
> when invoking `:make` could Vim not read and print the errorfile
> itself? This would avoid relying on shell features (which may not be
> portable).
>
> This may also alleviate the need to include a copy of `tee` in Vim's
> source for Windows systems.

You can drop "tee", but then you don't see any progress while make is
busy.

It should be possible to make this work, since tcsh works "out of the
box". An alternative would be to let make write to a file, and the Vim
would need to work like "tail -f" to show the output while it's working.
This does depend on make to flush the output, which would then be a new
problem to solve...

--
hundred-and-one symptoms of being an internet addict:
28. You have comandeered your teenager's phone line for the net and even his
friends know not to call on his line anymore.
Reply all
Reply to author
Forward
0 new messages