bug-bash
[Top][All Lists]
Advanced

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

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


From: Clark Wang
Subject: ``read -N n'' removes leading "\n"s
Date: Thu, 24 Nov 2016 16:08:19 +0800

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?

Thanks.

-clark

reply via email to

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