Subject: bug#28500: 25.3; shell mode starts echoing command

From: Barry Warsaw <[email-masked]>
Date: Tue, 19 Sep 2017 20:19:40 -0400

On Sep 19, 2017, at 09:36, Andreas Schwab <[email-masked]> wrote:
> 
> $ stty; openssl aes-256-cbc -in foo.txt -out foo.text.enc; stty

What is happening is that -echo is getting lost.  `stty -echo` after exiting Python will restore normal behavior in a shell buffer.  I’m not entirely sure why, but this is neither set nor necessary in a Terminal window.

My suspicion now falls on readline from home-brew.  Specifically, if I build Python from git master but *remove* the readline.<blah>.so file so there’s no way that readline can be invoked, then I don’t see the problem.  readline gets imported implicitly if available when entering the interactive prompt, and I’ve proven to myself that if that happens, echo gets reenabled.  It’s the common feature with sqlite3 too, which for me comes from brew.  Further, because openssl comes from Apple, it isn’t linked with brew’s readline and that does *not* exhibit the problem.

And then I found this: https://github.com/Homebrew/brew/issues/651

I will follow up on that issue, but it’s clearly now not an Emacs bug.

FWIW, this little bit of Python in your $PYTHONSTARTUP file will workaround the problem:

import sys
import atexit
import termios

# Reset `stty -echo` on exit.
def no_echo():
    flags = termios.tcgetattr(sys.stdin)
    flags[3] &= ~termios.ECHO
    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, flags)

atexit.register(no_echo)

Cheers!