Re: Commentary on: Bash Command Leads to ...

Chet Ramey <[email protected]>
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
On 2/2/26 5:17 PM, Stan Marsh wrote:

>> Bash saves the tty state before each foreground command, and restores the
>> saved tty settings if the command stops or terminates due to a signal.
>> Otherwise, the shell has to provide a builtin that mimics some or all of
>> `stty'.
> 
> I'm never quite sure what your posts mean, since you are, shall we
> say, (more than) a bit laconic.

You can say `terse'. It's ok.

> But for whatever it is worth, it is true that from time to time, I
> find myself in bash having to blind-type "stty sane^j" because some
> program has crashed out without fixing the terminal modes.  This never
> happens in tcsh.

Because tcsh has chosen to implement a builtin command (setty) that
controls the terminal settings tcsh allows external programs to
change.

> In fact,
> there is a program that I wrote (a long time ago) (and still use
> today) that puts the terminal into no-echo mode and, of course, resets
> the mode on a normal exit, but if it crashes out (which can happen),
> sometimes, in bash, it leaves the echo off.  I think when I wrote it,
> two things were true:
> 
>      1) I was trying to keep it as simple as possible, so did not
>      include the necessary signal handlers to ensure that the terminal
>      modes are always reset.

So not a well-behaved program. It doesn't exit due to a signal when run
in the foreground (otherwise bash would reset the terminal settings) but 
doesn't bother to reset the terminal settings it modifies before exiting.
This implies it has signal handlers, it just doesn't do enough in them.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.