Microsoft/vscode

Incorrect TerminalShellExecution exit code

Open

#237,517 建立於 2025年1月8日

在 GitHub 查看
 (3 留言) (0 反應) (1 負責人)TypeScript (10,221 fork)batch import
bughelp wantedterminal-shell-bash

倉庫指標

Star
 (74,848 star)
PR 合併指標
 (平均合併 11小時 43分鐘) (30 天內合併 1,000 個 PR)

描述

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.94.0
  • OS Version: macOS Sonoma 14.4

Steps to Reproduce:

  1. Listen for onDidEndTerminalShellExecution events
  2. Run a command that returns some exit code
  3. Type the same command and interrupt with ^C (i.e. interrupt without actually running the command)
  4. The exit code reported by the TerminalShellExecution event for the second execution (expected to be undefined since the command didn't actually run) will be the same as the previous command's exit code

For example:

$ echo test^C
-> exit code undefined
$ echo test
-> exit code 0
$ echo test^C
-> exit code 0
$ echo test^C
-> exit code 0
$ echo not test^C
-> exit code undefined
$ echo test^C
-> exit code undefined

From a quick look, this seems like caused by this code (marked as a hack): https://github.com/microsoft/vscode/blob/3b30f94f4f129e67be9b6c677aac582923da1fab/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts#L360-L370

貢獻者指南