bug-bash
[Top][All Lists]
Advanced

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

Re: ``read -N n'' removes leading "\n"s


From: Chet Ramey
Subject: Re: ``read -N n'' removes leading "\n"s
Date: Thu, 24 Nov 2016 10:43:57 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0

On 11/24/16 3:08 AM, Clark Wang wrote:
> See following example:
> 
> [STEP 100] # echo $BASH_VERSION
> 4.4.5(2)-release
> [STEP 101] # read -N 5 v
> abcd<ENTER>
> [STEP 102] # printf '%q\n' "$v"
> $'abcd\n'
> [STEP 103] # read -N 5 v
> <ENTER>
> <ENTER>
> abc[STEP 104] # printf '%q\n' "$v"
> abc
> [STEP 105] #
> 
> The second read did not return the leading "\n"s. According to the manual
> of read -N, "the result is not split on the characters in IFS" but I'm not
> sure how to understand this. Is the behavior correct?

This looks like a bug.  The -N option effectively sets the value of IFS to
"" for the duration of the read command, but it appears that splitting is
still following step 1 of

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_05


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



reply via email to

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