Open Bug 1289988 Opened 8 years ago Updated 2 years ago

Do something when terminal is mintty

Categories

(Firefox Build System :: General, defect)

defect

Tracking

(Not tracked)

People

(Reporter: glandium, Unassigned)

References

Details

It turns out that running mach (or any python for that matter) under mintty (which happens to be the default terminal emulator with msys2), makes sys.stdin/stdout/stderr be *non* ttys, which has multiple consequences:
- stdout is not line-buffered, which means in many cases, nothing is printed out
- things like the raw_input() function seem to want to open a tty, and consequently don't work in mintty. Combined with the above, for example, this leaves mach boostrap hanging printing nothing and not responding to input where it would normally print a message and expect the user to enter a number.
- mach itself relies on whether stdout is a tty to trigger auto-logging.
- while it doesn't work currently because of the lack of a curses package, mach output colorization relies on the same property.
- etc.

Even the python CLI doesn't work for the same reasons.

Fortunately, under normal conditions, we can detect the terminal emulator is mintty: in that case, the MSYSCON environment variable is set to mintty.exe. We can also distinguish between the process output being redirected to a file or being set to the terminal (S_ISREG vs. S_ISFIFO). But it's not straightforward to distinguish between terminal and pipe, since the terminal is actually using a pipe :(.

All that to say: We need to do something because things won't work properly under mintty, but the remaining question is: what?
This likely also explains why Mercurial doesn't behave well in mintty.
Isn't that what winpty is supposed to help with?
(In reply to Ryan VanderMeulen [:RyanVM] from comment #3)
> Isn't that what winpty is supposed to help with?

Yes, but aiui, you need to wrap all your commands with it.
We /could/ reexecute mach under it, but that would break `mach command | foo`
Product: Core → Firefox Build System
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.