ptybandage — make a program think that it is running interactively
ptybandage
{next-prog
}
ptybandage enables running programs that would change their functionality if their standard file descriptors are not terminal devices, in shell command pipelines. Such programs often alter their standard output buffering behaviour (switching from line buffered to fully buffered) or their use of terminal control sequences. When run via ptybandage, they will believe that they are running interactively on a terminal and behave accordingly, even if the input/output of ptybandage itself is redirected to a socket, pipe, or file.
If ptybandage is itself taking input directly from a terminal, it will operate in "terminal pass-through" mode.
It will set that terminal to non-canonical (i.e. "raw") mode for the duration, copying the prior mode to the pseudo-terminal that next-prog
is using.
If next-prog
stops with a signal, ptybandage will restore the prior terminal mode before stopping itself.
Upon continuing, it will put the terminal back into non-canonical mode and copy the prior mode across again.
It reflects all "window size" changes from its input terminal to the pseudo-terminal, too.
ptybandage combines pty-get-tty(1), pty-run(1), and open-controlling-tty(1) to run next-prog
with its standard input, output, and error routed through a pseudo-terminal.
It is a script that needs execlineb(1) as its script interpreter.
next-prog
may contain its own command line options, which pty-run will ignore.
See open-controlling-tty(1) for the environment and open file descriptors inherited by next-prog
.