[vim/vim] Terminal Buffer Closing Itself on Non-Zero Return Code (Issue #15017)

8 views
Skip to first unread message

Josh Dorsey

unread,
Jun 15, 2024, 6:31:39 PM (11 days ago) Jun 15
to vim/vim, Subscribed

Steps to reproduce

  1. On windows, launch vim.exe or gvim.exe with powershell set as the shell
C:\Program Files\Vim\vim90> type test.vimrc
set shell=\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\"

C:\Program Files\Vim\vim90> C:\Program Files\Vim\vim90\vim>vim.exe -Nu test.vimrc
  1. Open a terminal buffer, run some sort of command that uses ANSI sequences.
    • This is vague, I know, but multiple things trigger this for me. The quickest way is to compile the Zig hello world program (as described here). I also have a nodejs webpack build which causes this crash when the webpack-dev-server reports an error, and not when it doesn't. I've tried capturing the output of the zig build for reproduction, and wasn't able to, but I'll keep trying.
  2. The terminal buffer closes itself when the command completes, rather than returning to the shell's prompt. This closes the window regardless of how many nested shells are open.
    • This does not happen if the same terminal interaction is had via the command prompt application. The crash also happens with shell=C:\Program Files\Git\bin\bash.exe, and also happens with Git's bash.exe as the shell when it is nested (so it's not bash that's crashing, it's some interaction with vim). This also does not happen if the "Git Bash" application included with Git for Windows is used for the same terminal interaction outside of vim.
    • If ++noclose is used, the terminal tab is shown as 'finished'.

Expected behaviour

The same as the behavior exhibited by these shells outside of vim (or gvim), that it successfully returns to the prompt.

Version of Vim

9.0.2189

Environment

Operating System: Windows 10 22H2 (also seen on an older version, 20H?)
Git Version: 2.45.2, also seen on an older version 2.40.?
bash.exe --version: GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)
terminal: powershell.exe, but also happens in gvim
$TERM: outside vim/gvim there isn't an environment variable with that name
- powershell.exe reports it as undefined
- bash.exe reports TERM=cygwin within a vim terminal buffer and TERM=xterm-256color outside
A note: when powershell.exe is the shell in vim's terminal buffer there's a winpty-agent.exe running as a child of the vim process. This isn't the case when using Git's bash.exe so I don't think it's causing the issue. I mention it because :h terminal-ms-windows says it is no longer required in newer versions of Windows 10.

Logs and stack traces

When the terminal buffer closes, `:messages` shows nothing.

Messages maintainer: The Vim Project
E282: Cannot read from "nonexistent"
Press ENTER or type command to continue

I'm not sure where else to look, but there's no apparent error message.


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/15017@github.com>

Christian Brabandt

unread,
Jun 18, 2024, 8:06:40 AM (8 days ago) Jun 18
to vim/vim, Subscribed

I have no idea why this would close the buffer. Please try to capture all the output ANSI escape sequences. script(1) should be able to do it. But then we will need to figure out what's going on. Not sure how hard this will be.


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/15017/2175940019@github.com>

Josh Dorsey

unread,
Jun 18, 2024, 10:16:10 PM (8 days ago) Jun 18
to vim/vim, Subscribed

I noticed powershell spitting out an unparsed escape sequence, and printed it from a simple C program (although I'm sure there's a bash one-liner to print the same thing). This crashes powershell.exe/bash.exe/cmd.exe inside vim, and cmd.exe outside of vim. I'm not sure when it started crashing for cmd.exe outside of vim, but I did test that previously, where it wasn't crashing, and the issue isn't intermittent.

#include <stdio.h>

int main() {
    printf("\x1b[J\n");
}


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/15017/2177408082@github.com>

Reply all
Reply to author
Forward
0 new messages