Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0
On 7/1/20 7:25 AM, Greg Wooledge wrote:
> On Wed, Jul 01, 2020 at 07:51:00AM +0300, M. Nejat AYDIN wrote:
>> Is this intended behaviour of read builtin? If so where is it
>> documented? The Bash Reference Manual says only "If no names
>> are supplied, the line read is assigned to the variable REPLY."
>
> There you go. That is where it's documented. (That sentence also
> appears in the man page, at the end of the description of the read
> builtin.)
>
>> There is no mention of preserving leading and trailing white
>> spaces.
>
> How else would you interpret "the line read is assigned to the variable
> REPLY"? Read the line, assign it to the variable. Do not pass Go,
> do not perform IFS whitespace trimming.
I'd probably gloss over that interpretation and assume its behavior is
equivalent to specifying a single NAME. Then I'd run
`IFS= read << " x "`
to guarantee the behavior I wanted, even though it turned out to be
unnecessary.
So I learned something today. I guess it couldn't hurt to extend that
sentence with "without processing".
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
signature.asc Description: OpenPGP digital signature