Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: When is STTY ignored?

On May 30,  7:53am, Stephane Chazelas wrote:
} In:
} (STTY=-echo line; STTY=-echo line); line
} the "-echo" is only applied to the 2nd and 3rd "line"
} invocations (instead of 1st and 2nd).

So, this is a little odd.

The "stty" command is run only when isatty(0) and the process is the
group leader, i.e., the foreground job.

In the construct
    (command1; command2)
the group leader is the subshell, so STTY is ignored for command1;
but then command2 is optimized to an "exec" so it assumes the group
leadership and "stty" is run.  However, that exec means the subshell
is gone and there is never an opportunity to undo the setting change,
so it remains in effect after command2 exits, and that's why it
appears to have been applied to the 3rd command in your example.

This means we ought to treat having STTY in the environment as a
reason to skip the optimization.  However, I'm not sure we look for
STTY early enough in the call chain to handle this.  For example,
jobtab[thisjob].stty_in_env is only assigned after the decision is
made and the child has been forked.

Messages sorted by: Reverse Date, Date, Thread, Author