psysh (readline?) broken with tee #13200

Closed
opened 2026-01-31 03:36:29 +00:00 by claunia · 9 comments
Owner

Originally created by @chx on GitHub (Mar 26, 2021).

Windows Terminal version (or Windows build number)

1.6.10571.0

Other Software

psysh , Ubuntu tee

Steps to reproduce

  1. sudo apt install php-cli
  2. wget https://psysh.org/psysh ; chmod +x psysh
  3. ./psysh works normally
  4. ./psysh |tee foo

Observe no prompt and up arrow prints control characters. This was working with WSL1 a few days ago.

Expected Behavior

Well I wasn't expecting tee to completely break the terminal... I wouldn't be surprised if https://github.com/microsoft/terminal/issues/6096 https://github.com/microsoft/terminal/issues/4243 were the same.

Note it's possible to reproduce this without tee although it is way more complicated, you need Drupal and drush and drush-launcher but when running drush php (which executes an integrated psysh) via the launcher it is similarly broken vs vendor/bin/drush php is not broken.

I ran python |tee foo and got the same control characters although there at least the prompt didn't disappear.

Actual Behavior

Broken readline behavior.

Originally created by @chx on GitHub (Mar 26, 2021). ### Windows Terminal version (or Windows build number) 1.6.10571.0 ### Other Software psysh , Ubuntu tee ### Steps to reproduce 1. sudo apt install php-cli 1. wget https://psysh.org/psysh ; chmod +x psysh 1. ./psysh works normally 1. ./psysh |tee foo Observe no prompt and up arrow prints control characters. This was working with WSL1 a few days ago. ### Expected Behavior Well I wasn't expecting tee to completely break the terminal... I wouldn't be surprised if https://github.com/microsoft/terminal/issues/6096 https://github.com/microsoft/terminal/issues/4243 were the same. Note it's possible to reproduce this without tee although it is way more complicated, you need Drupal and drush and drush-launcher but when running `drush php` (which executes an integrated psysh) via the launcher it is similarly broken vs `vendor/bin/drush php` is not broken. I ran `python |tee foo` and got the same control characters although there at least the prompt didn't disappear. ### Actual Behavior Broken readline behavior.
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 03:36:29 +00:00
Author
Owner

@skyline75489 commented on GitHub (Mar 26, 2021):

Do you also see the same behaviour with cmd.exe?

@skyline75489 commented on GitHub (Mar 26, 2021): Do you also see the same behaviour with cmd.exe?
Author
Owner

@chx commented on GitHub (Mar 26, 2021):

What's the equivalent of tee for cmd?

@chx commented on GitHub (Mar 26, 2021): What's the equivalent of tee for cmd?
Author
Owner

@skyline75489 commented on GitHub (Mar 26, 2021):

No I mean you can run wsl.exe in cmd.exe to access the WSL environment, if that's what you're using. Or you can run ssh.exe and ssh into a Linux machine.

@skyline75489 commented on GitHub (Mar 26, 2021): No I mean you can run `wsl.exe` in cmd.exe to access the WSL environment, if that's what you're using. Or you can run `ssh.exe` and ssh into a Linux machine.
Author
Owner

@chx commented on GitHub (Mar 26, 2021):

Yes, I did win+r cmd and there I can reproduce there as well, every case I tried is reproducible. Closing here and filing with WSL2 instead.

@chx commented on GitHub (Mar 26, 2021): Yes, I did win+r cmd and there I can reproduce there as well, every case I tried is reproducible. Closing here and filing with WSL2 instead.
Author
Owner

@DHowett commented on GitHub (Mar 26, 2021):

This could still be on us! We actually own the terminal and the traditional Windows console.

There's a chance, however, that this is simply an application decision. Psysh or readline may be disabling some tty management that it would have otherwise done because it's not connected to a terminal any longer¹. I know that readline-based things don't love to be piped.

This actually reproduces in Linux straight-up, without the console or WSL:
image

¹ When its output is piped to tee, it can only detect that it's connected to a pipe; it can't tell that the other end of that pipe is also a terminal.

@DHowett commented on GitHub (Mar 26, 2021): This could still be on us! We actually own the terminal _and the traditional Windows console_. There's a chance, however, that this is simply an application decision. Psysh or readline may be disabling some tty management that it would have otherwise done because it's not connected to a terminal any longer¹. I know that readline-based things don't _love_ to be piped. This actually reproduces in Linux straight-up, without the console _or_ WSL: ![image](https://user-images.githubusercontent.com/189190/112659399-56217e80-8e22-11eb-9ffa-ac523df2c6e0.png) ¹ When its output is piped to tee, it can only detect that it's connected to a pipe; it can't tell that the other end of that pipe is also a terminal.
Author
Owner

@chx commented on GitHub (Mar 26, 2021):

@DHowett the big problem really is that somehow Drush Launcher is broken vs when running Drush , I just managed to replicate the behavior with tee ... for sure those are not broken on normal Linux. It's just waaaay more complicated to replicate that way. :/ I can try to write up replicate steps using perhaps docker to avoid installing half the world :/

@chx commented on GitHub (Mar 26, 2021): @DHowett the big problem really is that somehow Drush Launcher is broken vs when running Drush , I just managed to replicate the behavior with tee ... for sure those are not broken on normal Linux. It's just waaaay more complicated to replicate that way. :/ I can try to write up replicate steps using perhaps docker to avoid installing half the world :/
Author
Owner

@chx commented on GitHub (Mar 26, 2021):

Please try the Dockerfile at https://gist.github.com/chx/59de0d688e8e5ec17712d4665805bcc7 (this was copied and minimally adjusted from https://github.com/skilld-labs/docker-php/blob/master/php74/Dockerfile so thanks for that )

Once you have built it like docker build -t ghtest . you can compare docker run --rm -it ghtest /srv/vendor/bin/drush php to docker run --rm -it ghtest /usr/local/bin/drush php

@chx commented on GitHub (Mar 26, 2021): Please try the Dockerfile at https://gist.github.com/chx/59de0d688e8e5ec17712d4665805bcc7 (this was copied and minimally adjusted from https://github.com/skilld-labs/docker-php/blob/master/php74/Dockerfile so thanks for that ) Once you have built it like `docker build -t ghtest .` you can compare `docker run --rm -it ghtest /srv/vendor/bin/drush php` to `docker run --rm -it ghtest /usr/local/bin/drush php`
Author
Owner

@chx commented on GitHub (Mar 28, 2021):

OK I have been finally told that this is 100% not Windows Terminal fault. Sorry for the noise again, it's such a maze of intertwining components. I reopened https://github.com/drush-ops/drush-launcher/issues/90 and will work on that.

@chx commented on GitHub (Mar 28, 2021): OK I have been finally told that this is 100% not Windows Terminal fault. Sorry for the noise again, it's such a maze of intertwining components. I reopened https://github.com/drush-ops/drush-launcher/issues/90 and will work on that.
Author
Owner

@DHowett commented on GitHub (Mar 28, 2021):

Thanks for following up!

@DHowett commented on GitHub (Mar 28, 2021): Thanks for following up!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13200