Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Unexpected stdin-behavior
- X-seq: zsh-workers 49515
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Tycho Kirchner <tychokirchner@xxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Unexpected stdin-behavior
- Date: Fri, 22 Oct 2021 11:58:27 +0100 (BST)
- Archived-at: <https://zsh.org/workers/49515>
- Importance: Medium
- In-reply-to: <CAH+w=7Y_3DBPO=AfYBnKmFUN3cdffGB=65z4BepmtQBJgBGd9w@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <2abd99f9-c1c0-1385-f8b4-be9b8f14c4d9@mail.de> <CAH+w=7Ype8LCU4nywbNwjbTQ4G6sfa3yihNfZUtsnLBi7CJ0kA@mail.gmail.com> <13d30855-d91c-7def-6834-f0ec24cfd598@mail.de> <CAH+w=7Y_3DBPO=AfYBnKmFUN3cdffGB=65z4BepmtQBJgBGd9w@mail.gmail.com>
> On 21 October 2021 at 20:14 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Thu, Oct 21, 2021 at 9:47 AM Tycho Kirchner <tychokirchner@xxxxxxx> wrote:
> > thanks for your response. Could you please elaborate how your answer
> > explains the difference in the output between the commands
> > zsh -s and
> > zsh -s -i
> > ?
>
> When -i is NOT present, stdin is set to line buffered for the stdio library.
>
> I don't actually see any difference between -s and -s -i except for
> the printing of the prompt, when I try it with the latest development
> version, and the only code difference is the removal of stdio. This
> is probably an unintentional behavior change in the new code, and may
> bear looking into.
>
> For zsh-workers (particularly PWS), I'm referring to this bit of code in init.c:
>
> /*
> * Finish setting up SHIN and its relatives.
> */
> shinbufalloc();
> if (isset(SHINSTDIN) && !SHIN && unset(INTERACTIVE)) {
> #ifdef _IONBF
> setvbuf(stdin, NULL, _IONBF, 0);
> #else
> setlinebuf(stdin);
> #endif
> }
>
> We either don't need the set*buf business at all, or we need its
> equivalent for shinbuf, I think.
That _IONBF is (and has always been) inconsistent with setlinebuf(), surely?
It means no buffering.
As far as shinbuf itself is concerned, is the most logical behaviour
line buffering (i.e. read ahead only up to a \n) if interactive?
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author