NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: set -o emacs ; stty -echo



In article <29555.1665280852%jacaranda.noi.kre.to@localhost>,
Robert Elz  <kre%munnari.OZ.AU@localhost> wrote:
>    Date:        Tue, 19 Jul 2022 21:34:27 -0400
>    From:        Andrew Cagney <andrew.cagney%gmail.com@localhost>
>    Message-ID: 
><CAJeAr6uPi8DV4LQY4bjZnFteqbKZtKmZDqWT2C1kLDBd6p8wig%mail.gmail.com@localhost>
>
>  | should, like for bash, this put the terminal into -echo mode?
>  |
>  | arm64$ echo $SHELL
>  | /bin/sh
>  | arm64$ set -o emacs ; stty -echo
>  | arm64$ pwd
>  | /home/cagney
>  |
>  | other combinations are equally puzzling.  for instance:
>  |
>  | set -o emacs ; stty -echo ; set +o emacs
>  | doesn't flip to -echo mode either
>
>Sorry this has taken so long for (my part of) looking into this.
>
>I am now confident that sh has nothing to do with this at all, in
>fact, sh never makes any changes (by itself) to any of the terminal
>operating modes -- it will check to see if the line discipline happens
>to be the old one (which I don't think exists on NetBSD any more, and
>probably not anywhere else relevant either) but if it is, all it does is
>refuse to enable job control, it doesn't even attempt to alter it.
>
>Aside from that, the only tty/sh interactions are to change the terminal's
>process group as needed as the foreground job alters, turn off O_NONBLOCK
>if someone stupidly set it on the shell's input stream (whether a terminal
>or otherwise) and monitor the window width of stdout (if a tty) for some
>output to be able to be wrapped better.
>
>Everything else related to tty modes is handled entirely by libedit.
>Hence, I am passing this to Christos to look at.

Well, this is a libedit messing with the tty settings. By default it
ignores changes to some tty settings (for example "echo" so that curses
program that coredump don't end up mystifying nubs). You can see/change
how it behaves using the built-in "setty", which you can access anytime
by hitting M-x:

$ set -o emacs
$ x 
: setty
iflag:-inlcr -igncr +icrnl 
oflag:+opost +onlcr -onlret 
cflag:
lflag:+isig +icanon +echo +echoe -echonl -noflsh +echoctl -flusho +iexten 
      -extproc 
chars:

Here -<foo> means clear, +<foo> means set. You can use the "setty" to change
them. See editrc(5).

christos



Home | Main Index | Thread Index | Old Index