Some program started in a large script is doing
stty -echo. I'm not sure which program it is so I have to try to find it by trial and error. Is
</dev/null 2>&1 | tee /dev/null sufficient to block programs from accessing the terminal, or is there another way to get access to the terminal?
Actually I was unable to determine which program accesses the terminal (attempts to
strace the entire script produced a 17MB file without
tcsetattr, so I assume the terminal modifications are just writes of control characters). The problem was also non-deterministic; it was sometimes interfering with the terminal and sometimes not.
Placing the following prelude in the script
seemed to stop interference with the terminal doesn't fix the problem. However, it's not clear why it doesn't fix the problem: are processes still accessing the terminal through
/dev/tty, or are escape codes written by the programs still being dumped to the terminal by
MKTEMP="$(mktemp)" mkfifo "$MKTEMP".fifo ( set +o xtrace cat "$MKTEMP".fifo rm -f "$MKTEMP".fifo "$MKTEMP" ) </dev/null 2>&1 & exec 1>"$MKTEMP".fifo exec 2>&1 exec 0</dev/null