[GH-ISSUE #49] Check whether stderr is a tty if writing to stderr #45

Open
opened 2026-03-02 23:01:58 +03:00 by kerem · 0 comments
Owner

Originally created by @xmo-odoo on GitHub (May 14, 2021).
Original GitHub issue: https://github.com/agrinman/tunnelto/issues/49

While writing up #48 I found a bit of an odd behaviour in tunnelto: although it apparently writes its output to stderr, it doesn't check whether stderr is a tty, instead it checks stdout:

$ tunnelto 2>test.txt

will write a bunch of ANSI escape codes to test.txt, but

$ tunnelto > /dev/null 2>test.txt

will not.

So when writing a script around tunnelto, despite only reading from stderr one has to redirect stdout in order to avoid an output full of ANSI.

Originally created by @xmo-odoo on GitHub (May 14, 2021). Original GitHub issue: https://github.com/agrinman/tunnelto/issues/49 While writing up #48 I found a bit of an odd behaviour in tunnelto: although it apparently writes its output to `stderr`, it doesn't check whether `stderr` is a tty, instead it checks stdout: $ tunnelto 2>test.txt will write a bunch of ANSI escape codes to `test.txt`, but $ tunnelto > /dev/null 2>test.txt will not. So when writing a script around tunnelto, despite only reading from stderr one has to redirect `stdout` in order to avoid an output full of ANSI.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tunnelto#45
No description provided.