Note that there are some explanatory texts on larger screens.

plurals
  1. POTerminal emulator implementation - problems with repeated input
    primarykey
    data
    text
    <p>I am trying to implement a terminal emulator in Java. It is supposed to be able to host both cmd.exe on Windows and bash on Unix-like systems (I would like to support at least Linux and Mac OS X). The problem I have is that both <code>cmd.exe</code> and <code>bash</code> repeat on their standard output whatever I send to their standard input.</p> <p>For example, in bash, I type "<code>ls</code>", hit enter, at which point the terminal emulator sends the input line to bash's stdin and flushes the stream. The process then outputs the input line again "<code>ls\n</code>" and then the output of the <code>ls</code> command.</p> <p>This is a problem, because other programs apart from <code>bash</code> and <code>cmd.exe</code> don't do that. If I run, inside either bash, or <code>cmd.exe</code>, the command "<code>python -i</code>", the python interactive shell does not repeat the input in the way <code>bash</code> and <code>cmd.exe</code> does. This means a workaround would have to know what process the actual output came from. I doubt that's what actual terminal emulators do.</p> <p>Running "<code>bash -i</code>" doesn't change this behaviour. As far as I know, <code>cmd.exe</code> doesn't have distinct "interactive" and "noninteractive" modes.</p> <hr> <p><strong>EDIT:</strong> I am creating the host process using the <code>ProcessBuilder</code> class. I am reading the stdout and stderr and writing to the stdin of the process using a technique similar to the <a href="http://www.physionet.org/physiotools/puka/sourceCode/puka/StreamGobbler.java" rel="nofollow">stream gobbler</a>. I don't set any environment variables before I start the host process. The exact commands I use to start the processes are <code>bash -i</code> for bash and <code>cmd</code> for cmd.exe. I'll try to post minimal code example as soon as I manage to create one.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload