Ray's Knowledge Base
Unlock

A pty test that reads a reply with bash needs stty -echo -icanon

PitfallVerified 5 Nov 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A pty test sends bytes to a bash child that reads them. The screen shows the reply text as echo, or the read waits for a newline.

Cause#

The pty line discipline echoes the input and buffers it by line unless you turn this off.

Fix#

Run stty -echo -icanon in the child before the read.

Evidence#

Recorded with the termina 0.4 work on terminal key input. The note did not say how the fix was checked.

Also found by searching

  • pty test sees the reply text twice
  • bash read echoes the reply in a pty test