msys2 / msys2/msys2.github.io

mintty.exe is a strange terminal

Open
#134 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
3.3k
Forks
446
Avg merge
2h 16m
Merged PRs (30d)
1

Description

It would be really nice if somebody could look at the following issue:
https://github.com/golang/go/issues/46681

It demonstrates the fact that git-bash.exe and also mingw.exe really behave strange, when we want to the get the controlling terminal file input CONIN$ on windows.

This is basically done in GO with:

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"syscall"

	"golang.org/x/term"
)

func GetCttyIn() (io.Reader, error) {
	in, err := syscall.Open("CONIN$", syscall.O_RDWR, 0)
	if err != nil {
		return nil, err
	}

	fmt.Println("$CONIN Isterm: ", isatty.IsTerminal(uintptr(in)))

	return os.NewFile(uintptr(in), "/dev/tty"), nil
}

func main() {

	fmt.Println("In: ", term.IsTerminal(int(os.Stdin.Fd())))
	fmt.Println("Out: ", term.IsTerminal(int(os.Stdout.Fd())))

	in, err := GetCttyIn()
	if err != nil {
		panic(err)
	}
	scanner := bufio.NewScanner(in)

	success := scanner.Scan()
	if !success {
		panic(err)
	}
	fmt.Println("Res:", scanner.Text())
}

Running the above with echo "asd" | go run main.go
in vs code integrate terminal with bash.exe (MSYS2) **works **(suprisingly) but

running it in the git-bash.exe or msyswin64.exe (mintty.exe) does not work:

VS Code: (bash.exe)

In:  false
Out:  true
$CONIN Isterm:  true
asd
Res: asd

Correct!

Straight mintty.exe

In:  false      
Out:  false  // <<<< Thats wrong!
$CONIN Isterm:  true
                 //  <<<<--- STUCK at READ here!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Go issue and the main.go reproduction shown in this report; run it with echo "asd" | go run main.go under the listed terminals. Done means the CONIN$ read no longer gets stuck in mintty.exe and matches the working bash.exe behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, shell
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.