help-bash
[Top][All Lists]
Advanced

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

Strange behaviour of read builtin


From: M. Nejat AYDIN
Subject: Strange behaviour of read builtin
Date: Wed, 1 Jul 2020 07:51:00 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

When a variable name is supplied to the read builtin, leading and
trailing white spaces are stripped from the input:
    read line <<< " x "; echo "[$line]"
outputs
    [x]
as expected.
If no names are supplied then leading and trailing white spaces are
preserved:
    read <<< " x "; echo "[$REPLY]"
outputs
    [ x ]
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 is no mention of preserving leading and trailing white
spaces.


reply via email to

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