Skip to content

winpty aliases applied unnecessarily in Windows Terminal; break env var cygpath rewriting #5960

@cspotcode

Description

@cspotcode

Existing issues matching what you're seeing

  • I was not able to find an open or closed issue matching what I'm seeing

Git for Windows version

git version 2.52.0.windows.1

Windows version

Windows 11

Windows CPU architecture

x86_64 (64-bit)

Additional Windows version information

Microsoft Windows [Version 10.0.26100.7171]
(c) Microsoft Corporation. All rights reserved.

Options set during installation

Editor Option: VisualStudioCode
Custom Editor Path: 
Default Branch Option: main
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: LFOnly
Bash Terminal Option: ConHost
Git Pull Behavior Option: FFOnly
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Enabled
Enable FSMonitor: Disabled

Other interesting things

No response

Terminal/shell

Git Bash

Commands that trigger the issue

# Run from "Git Bash" in a "Windows Terminal" window. Also works in VSCode's integrated terminal
# We get the winpty alias outside of mintty
$ command -v node
alias node='winpty node.exe'

# This happens because $TERM is set:
$ echo $TERM
xterm-256color

# We still have a functional TTY even *without* the alias. This means the alias is unnecessary outside of mintty, right?
$ node.exe -p process.stdout.isTTY # Bypass the alias.
true

# Problem: winpty breaks common scripting scenarios, such as piping
$ node -p process.versions | grep v8
stdout is not a tty

# It *should* work like this:
$ node.exe -p process.versions | grep v8
  v8: '9.6.180.15-node.15',

# Problem: winpty breaks env var path conversions
$ ( WORKDIR='/c/Users/me/projects/libfoo' node -p '({TEMP: process.env.TEMP, WORKDIR: process.env.WORKDIR})' )
{
  TEMP: 'C:\\Users\\me\\AppData\\Local\\Temp',
  WORKDIR: '/c/Users/me/projects/libfoo'
}

# Expected WORKDIR to be converted like below: (bypassing alias with exec)
$ ( WORKDIR='/c/Users/me/projects/libfoo' exec node -p '({TEMP: process.env.TEMP, WORKDIR: process.env.WORKDIR})' )
{
  TEMP: 'C:\\Users\\me\\AppData\\Local\\Temp',
  WORKDIR: 'C:/Users/me/projects/libfoo'
}

Expected behaviour

When invoking node, winget, etc from Git Bash in Windows Terminal:

  • env vars and positional arguments are treated the same as with all other commands
  • piping, output capture, and other shell-isms work as expected

The above should be true because:

  • winpty bash aliases are not declared outside of mintty

Can this be accomplished by checking something other than $TERM? Check TERM_PROGRAM="mintty", check exit code of tty -s?

Actual behaviour

node, winget, etc are aliased as winpty node, winpty winget, etc.

Env vars are not converted consistently compared to other, non-aliased commands.

Repository

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions