[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inconsistent output in terminal emulator
From: |
Chet Ramey |
Subject: |
Re: Inconsistent output in terminal emulator |
Date: |
Sat, 22 Aug 2009 20:30:41 -0400 |
User-agent: |
Thunderbird 2.0.0.22 (Macintosh/20090605) |
Bob Proulx wrote:
> nico raffo wrote:
>> I'm writing a simple terminal emulator (on linux using standard pty
>> libraries) and have run across some behavior in bash that I cannot
>> explain after several weeks of reading documentation.
>
> I am not sure of the exact cause of your trouble. But having been a
> few days and no one else suggesting anything I thought I would jump in
> anyway.
>
> Hopefully you will be using a free license on your code? And then you
> could post it and perhaps someone might see something in it then.
>
>> However with bash, the shell doesn't respond at all until a
>> <CR> is sent, and then bash only sends the output of the command, not
>> the command itself. If my terminal emulator is expecting the shell to
>> provide all display text, it wouldn't show the commands at all.
>
> This seems like you are tripping into the difference between different
> tty driver settings of raw mode and canonical input mode (aka cooked
> mode).
I think it's how the terminal emulator sets the ECHO flag in the
termios local status word (c_lflag & ECHO). If that bit is set,
readline echoes the text it reads back to the terminal. If it's
not, readline assumes that the terminal is in no-echo mode and that
it should not echo the characters.
I assume that the difference between bash and zsh is that zsh sets
the ECHO bit and leaves it set when it exits. A subsequent invocation
of bash picks up that flag and echoes input as a result.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/