pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: abysmal check-portability speed



On Wed, Sep 25, 2024 at 10:12:32PM +0200, Thorsten Glaser wrote:
> >That looks like a bug to me
> 
> No, it works *exactly* as documented.
> 
> >, though the mksh doc for read -n is fairly pathetic
> 
> Huh?
> 
>     -n z   Instead of reading till end-of-line, read up to z bytes but
> 	   return as soon as any bytes are read, e.g. from a slow ter?
> 	   minal device, or if EOF or a timeout occurs.
> 

Bash man page:

-n nchars
	read returns after reading nchars characters rather than
	waiting for a complete line of input, but
	honors a delimiter if fewer than nchars characters are
	read before the delimiter.
-N nchars
	read returns after reading exactly nchars characters
	rather than waiting for a complete line of input,
	unless EOF is encountered or read times out.  Delimiter
	characters encountered in the input are not treated
	specially and do not cause read to return until nchars
	characters are read.  The result is not split on the
	characters in IFS; the intent is that the variable is
	assigned exactly the characters read (with the
	exception of backslash; see the -r option below).

So mksh used '-n' the way bash uses '-N'.

The majority seem to treat '-n count' like bash.

I, for one, would have chosen '-b' (bytes or binary i.e. read exactly
that, implying '-r') for mksh '-n' aka bash '-N'.

And just to add fuel to the fire, in the (more common)
interpretation of '-n' (a line but stop at count if end not reached),
the count should be the count of bytes read, with the exception of the
continuation line sequences because of consistency:

When inputing any other thing not quoted, it yields the same result
with or without continuation lines because they are ignored. It shall be
the same with "read -n count". The result should not depend on the
presence or absence of continuation lines.

-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index