read -d 'z' a < <(printf 'a\n\n\n'); printf "$a"
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"
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:
but the actual output is:
read doesn't remove the excess trailing
IFS characters (in this case