Whilst running a command that accepts stdin, such as wc or cat without any arguments, stdin should be echoed back to stdout a character at a time. This PR does this in the getChar() that is monkey-patched into the command's WASM wrapper. It only does so if stdout is the terminal, if it is a file for example then it is not echoed. Perhaps the code should alternatively go in TerminalInput, but then that would need access to the current TerminalOutput too.
It is not fully correct for the situation of cat accepting multiple lines of input, as here all the output is written at once at the end of the command. What should actually happen is that the command should write each line after it receives a carriage return. I think this occurs because the WASM commands are not set up to perform line buffering. There are a number of similar issues around input/output handling of the WASM commands that will be dealt with in due course.
Whilst running a command that accepts stdin, such as
wc
orcat
without any arguments, stdin should be echoed back to stdout a character at a time. This PR does this in thegetChar()
that is monkey-patched into the command's WASM wrapper. It only does so if stdout is the terminal, if it is a file for example then it is not echoed. Perhaps the code should alternatively go inTerminalInput
, but then that would need access to the currentTerminalOutput
too.It is not fully correct for the situation of
cat
accepting multiple lines of input, as here all the output is written at once at the end of the command. What should actually happen is that the command should write each line after it receives a carriage return. I think this occurs because the WASM commands are not set up to perform line buffering. There are a number of similar issues around input/output handling of the WASM commands that will be dealt with in due course.