From: John Cowan <xxxxxx@ccil.org>
Date: Friday, August 09, 2019 12:48 PM

On Fri, Aug 9, 2019 at 12:26 PM <xxxxxx@ancell-ent.com> wrote:
 
[ The raison d'etre of these procedures: best possible effort to not leave tty in a broken mode after program exit. ]

I'm still thinking we should expose below these fancy procedures the system calls, struct, and flags primitives they use to get and set line disciplines.  My arguments now are that:

Perhaps your Scheme's dynamic-wind isn't so magic, or doesn't exist.

Your POSIX changing line discipline loses characters when switching from canonical mode, I don't think we can demand all implementations of POSIX a Scheme runs on to be perfect.  The scenario I conceive of here is that between invocations of e.g. with-rare-mode a character gets in the canonical mode domain and then is "flushed" in POSIX terms, that is discarded, when we return to raw mode, despite using the NOW option for that.

Your POSIX line discipline doesn't allow setting everything we assume it can.  For historical reasons you're actually required to get, set, which will return 0 if any of the changes are accepted, then get again to make sure all or "enough" of the changes were made.  Which also brings up the question about what we should do with these procedures if that happens.
 
Which if you'd just allow setting timeouts to 1/10 second or so granularity I suspect I'd come to really like.

Okay.  How about this:  Change seconds to deciseconds in the existing description of with-raw-mode, add (with-rare-mode port thunk).  Seconds was just a brain fart on my part: I had forgotten that VMIN Is measured in deciseconds.

According to ... Wikipedia, rare/cbreak mode, which I've not actually used, is for character at a time input.  Does that mean with-rare-mode should hang until it gets a character, or should it (can it?) use the timeout line discipline feature that with-rare-mode uses. 

 Is there any circumstance where you'd like raw or rare mode not echoing?

Probably not.  Okay, make with-raw-mode and with-rare-mode turn off and restore echoing.

  Many web user interfaces and e.g. Gnu Emacs "echo" password characters with "."  Which does give an attacker looking over your shoulder a very important piece of information,

I have seen versions that output a random (1-3, say) number of dots.  This is useful for knowing whether or not your keystroke registered at all, often an issue on modern crappy keyboards.

Ugh, that sounds like a horrible "feature".  But I think we should allow for "magic echo", a dot per typed character, and rubout deleting the last dot.  Maybe ^U the whole set of characters typed.

Is there any other (non-evil :-) use case for no echo than typing in a password or pass phrase??

Not that I can think of, but that's just me.  Nevertheless, managing a tty in cooked mode is simpler (basically just another file, no timeouts or rubouts to manage), and if you don't want this sort of magic echo (which would be a great thing for a higher-level procedure to provide)

One we should either provide, or provide the system calls to allow the creation of.

you can just wrap with-no-echo around your read-line or whatever and have done with it.

Indeed.

- Harold