zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: When is STTY ignored?
Date: Tue, 30 May 2017 23:27:51 -0700	[thread overview]
Message-ID: <170530232751.ZM27464@torch.brasslantern.com> (raw)
In-Reply-To: <20170530065302.GA6568@chaz.gmail.com>

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.


      reply	other threads:[~2017-05-31  6:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 20:36 Stephane Chazelas
2017-05-30  0:02 ` Bart Schaefer
2017-05-30  6:53   ` Stephane Chazelas
2017-05-31  6:27     ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=170530232751.ZM27464@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).