bug-bash
[Top][All Lists]
Advanced

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

Re: read -N ignores IFS


From: Chet Ramey
Subject: Re: read -N ignores IFS
Date: Mon, 06 Apr 2015 11:20:22 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 3/29/15 5:03 AM, isabella parakiss wrote:
> $ read -n 100 a b <<< 'x y'; declare -p a b
> declare -- a="x"
> declare -- b="y"
> $ read -N 100 a b <<< 'x y'; declare -p a b
> declare -- a="x y
> "
> declare -- b=""
> 
> From my understanding of the documentation, read -N should ignore the
> delimiter (-d), not the IFS.  If the current behaviour is correct, a
> better wording may be helpful.

Yes, it appears that the current wording leads to invalid assumptions
about the behavior of -N.  The feature is implemented as Richard Stallman
originally requested it:

"We want to make a shell script reliably read the first few characters
from standard input and save them in a variable...I suggest an option for
`read' that says to read exactly a certain number of characters.  Perhaps
`read -c NUMBER'."

There was some back-and-forth back in late 2009 about features and
syntax and the current implementation is the result.  I proposed a
combination of -n, -d DELIM, and $REPLY, but rms's request was for a
more general mechanism.  (-N does not imply -r, though maybe, in
hindsight, it should have.)

The text reading "read exactly N characters" was intended to imply this,
but I can make it more explicit.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]