This command:
read -d 'z' a < <(printf 'a\n\n\n'); printf "$a"
outputs:
a
bash's read
removes excess trailing newlines which is expected.
and by changing the IFS
to null character:
IFS= read -d 'z' a < <(printf 'a\n\n\n'); printf "$a"
it outputs:
a
(blank line)
(blank line)
read
no longer removes the excess trailing newlines since IFS
no longer includes newline character ...
but now if we do the same but with m
instead of newlines:
IFS=m read -d 'z' a < <(printf 'ammm'); printf "$a"
one would think the output would be:
a
but the actual output is:
ammm
i.e. now read
doesn't remove the excess trailing IFS
characters (in this case m
character).
why?