I need to modify the output of a program that asks for tty input. When I pipe the output of the program to a utility such as
sed however, lines of input don't show.
As a specific if trivial example: I'd like to take the normal Scala input, which includes a REPL prompt:
$ scala Welcome to Scala 2.12.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60). Type in expressions for evaluation. Or try :help. scala>
And change all occurrences of
$ scala | sed 's/Java/Mocha/g' Welcome to Scala 2.12.3 (Mocha HotSpot(TM) 64-Bit Server VM, Mocha 1.8.0_60). Type in expressions for evaluation. Or try :help.
The problem is that neither the last line (
scala>) nor any keyboard input typed is shown until after
[Enter] is pressed. I'd like for the second version to behave as the first, only with the
sed substitution (and not substitution of keyboard input, of course). Is this possible?
(A portable solution is best, of course, but in case the only solution is shell- or distro-specific, I'd ideally like Zsh and BSD. Thanks.)