From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Opts -i and -s no longer work together, haven't for while
Date: Sun, 12 Oct 2014 10:42:56 -0700 [thread overview]
Message-ID: <141012104256.ZM23702@torch.brasslantern.com> (raw)
In-Reply-To: <20141012180616.71de2c1e@pws-pc.ntlworld.com>
On Oct 12, 6:06pm, Peter Stephenson wrote:
}
} -s being the part of the business that has been ignored, it's hard to
} see how making it take precedence now can break anything that was
} working and that logically should have worked. So it all sounds fine
} to me.
Here's a revised patch that also fixes a couple of other small items:
I added a bit more detail to the comment in parseargs() because the
comment mentioning init_io() was removed from zsh_main().
The caller of init_io() expects that shout might become NULL, but the
setvbuf() call in init_io() did not consider that possibility.
The word "interative" in a comment was a typo.
diff --git a/Src/init.c b/Src/init.c
index 6d005dc..68d3612 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -243,12 +243,24 @@ parseargs(char **argv, char **runscript)
*/
opts[MONITOR] = 2; /* may be unset in init_io() */
opts[HASHDIRS] = 2; /* same relationship to INTERACTIVE */
+ opts[USEZLE] = 1; /* see below, related to SHINSTDIN */
opts[SHINSTDIN] = 0;
opts[SINGLECOMMAND] = 0;
if (parseopts(NULL, &argv, opts, &cmd, NULL))
exit(1);
+ /*
+ * USEZLE remains set if the shell has access to a terminal and
+ * is not reading from some other source as indicated by SHINSTDIN.
+ * SHINSTDIN becomes set below if there is no command argument,
+ * but it is the explicit setting (or not) that matters to USEZLE.
+ * USEZLE may also become unset in init_io() if the shell is not
+ * interactive or the terminal cannot be re-opened read/write.
+ */
+ if (opts[SHINSTDIN])
+ opts[USEZLE] = (opts[USEZLE] && isatty(0));
+
paramlist = znewlinklist();
if (*argv) {
if (unset(SHINSTDIN)) {
@@ -603,7 +615,7 @@ init_shout(void)
if (SHTTY == -1)
{
- /* Since we're interative, it's nice to have somewhere to write. */
+ /* Since we're interactive, it's nice to have somewhere to write. */
shout = stderr;
return;
}
@@ -616,7 +628,8 @@ init_shout(void)
/* Associate terminal file descriptor with a FILE pointer */
shout = fdopen(SHTTY, "w");
#ifdef _IOFBF
- setvbuf(shout, shoutbuf, _IOFBF, BUFSIZ);
+ if (shout)
+ setvbuf(shout, shoutbuf, _IOFBF, BUFSIZ);
#endif
gettyinfo(&shttyinfo); /* get tty state */
@@ -1608,8 +1621,7 @@ zsh_main(UNUSED(int argc), char **argv)
emulate(zsh_name, 1, &emulation, opts); /* initialises most options */
opts[LOGINSHELL] = (**argv == '-');
opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid());
- opts[USEZLE] = 1; /* may be unset in init_io() */
- /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
+ /* sets ZLE, INTERACTIVE, SHINSTDIN and SINGLECOMMAND */
parseargs(argv, &runscript);
SHTTY = -1;
--
Barton E. Schaefer
prev parent reply other threads:[~2014-10-12 17:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-11 6:12 Bart Schaefer
2014-10-11 16:52 ` Bart Schaefer
2014-10-11 20:07 ` Bart Schaefer
2014-10-12 17:06 ` Peter Stephenson
2014-10-12 17:42 ` 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=141012104256.ZM23702@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).