fak
faketty
cargo install faketty
fak

faketty

Wrapper to exec a command in a pty, even if redirecting the output

by David Tolnay

1.0.7 (see all)License:MIT OR Apache-2.0
cargo install faketty
Readme

faketty

github crates.io build status

A wrapper binary to exec a command in a pty, even if redirecting the output.

This allows logging the stdout and stderr (separately) of a process, without the output being different from what you'd see in the terminal if you weren't logging anything.

$ cargo install faketty
$ faketty bazel build :target >log/out 2>log/err
          ~~~~~~~~~~~~~~~~~~~ command to run

Background

When redirecting stdout/err to a pipe or file, a process may detect the output is no longer going to a tty (because it has no width/height, baud rate, etc) and may change its behavior accordingly. For example many programs that involve a progress bar or colored text in a terminal disable those things when the output is not going to a terminal.

There is a script(1) command which makes it possible to redirect a command's terminal-style output by executing it inside a pseudoterminal (pty) – a bidirectional pipe that also has width, height, etc and tricks the process into thinking it is talking to a real terminal. However, script only uses a single pty, which makes it impossible to demultiplex stdout and stderr to different places.

The faketty command in this repo is similar to script --quiet --return --command '...' /dev/null except that it preserves distinct stdout and stderr streams.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this program by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

GitHub Stars

66

LAST COMMIT

13d ago

MAINTAINERS

1

CONTRIBUTORS

2

OPEN ISSUES

1

OPEN PRs

0
VersionTagPublished
1.0.7
11d ago
1.0.6
13d ago
1.0.5
2mos ago
1.0.4
2mos ago
No alternatives found
No tutorials found
Add a tutorial