Tyrrrz / CliWrap

Library for running command-line processes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can STDIN fake being a TTY?

chris-findlay opened this issue · comments

Details

Some commands (e.g. ls or docker) output differently based on the result of calling isatty(3), e.g. different formats or using cursor control escape codes to keep the output tidy.

Is there any way to get a process run from .Net to get a true answer from that check so it thinks it's outputting to a terminal?

I really like the look of this lib, but if it can manage the above, then switching to it will be an easy sell. (c:

...for that matter, can .Net tell if it's connected to a TTY for output?

I know most .NET programs use Console.IsOutputRedirected to check if they are in a terminal. When running a process with CliWrap, the output of that property will be true. You can fake a terminal by wrapping it instead -- i.e. instead of Cli.Wrap("foo") do Cli.Wrap("/bin/sh").WithArguments(...). In this case, the output of the underlying process (launched by sh) will not be considered redirected.

Now that you mention it, that seems obvious - thanks heaps.