On Tue, 14 Oct 2025 16:08:55 +1300, Martin D Kealey wrote:
> 1. Explicitly define the behaviour or «read -t0 -N0» as a non-destructive
> lookahead, while deprecating «read -t0» without «-N0» for this purpose.
> 2. Alter «read -t0 -N$count» to place up «$count» bytes of input in
> «REPLY», but only from what is already available. In particular, when
> reading from a pipe, it consumes exactly the whole content of the kernel's
> pipe buffer (½KiB for POSIX; 4KiB or one vmpage for Linux) provided that
> «$count» is large enough).
> 3. Alter «read -t0 -d$'\n'» to place a line of input in «REPLY» if one is
> already available. If only a partial line of input is available (missing a
> newline), then:
>   (3a) when reading from a tty that's already in ICANON (“cooked”) mode,
> «REPLY» is left empty without consuming any input; and
>   (3b) in all other cases, any input that is consumed is placed in «REPLY»,
> but the consumption is unspecified and explicitly documented as “may
> change”.
> 4. Alter «read -t0 -n0 -d$'\n'» to perform look-ahead while remaining in
> ICANON mode.
> 5. The behaviour «read -t$non_zero -N$count» and «read -t$non_zero -d$'\n'»
> be stabilized to be consistent with (1) through (4); in particular, this
> means that any SIGALRM timer should not start until after a non-blocking
> read has reported «EAGAIN».
> 6. The behaviour of «-d» with something other than $'\n' be made as
> consistent as possible with (1) through (5) (As an implementation detail,
> when reading from a tty, it would be nice to use «termios.c_cc[VEOL]» for
> «-d» on systems that support it.)
> 
> If there's interest, I'll see if I can work up suitable patches.

Martin, I am greatly interested in this. Regretfully, my programming skills
are not at a level where I can help.  I do hope that this discussion will 
result in an actual patch for the proposed changes.

-Pourko



Reply via email to