Ulrich Mueller
2016-10-30 11:57:46 UTC
While discussing some updates for the Gentoo developer manual, the
question arose if a construct like the following is officially
supported Bash behaviour:
while IFS="" read -d '' -r f ; do
echo "Calling down holy vengance upon $f"
done < <(find "${S}" -type f -print0)
Apparently "read -d ''" or "read -d $'\0'" have some real-world use:
http://unix.stackexchange.com/questions/61029/why-is-0-the-same-as
http://stackoverflow.com/questions/8677546/bash-for-in-looping-on-null-delimited-string-variable
However, according to the documentation:
'-d DELIM'
The first character of DELIM is used to terminate the input
line, rather than newline.
An empty string has no first character, so strictly speaking -d ''
would be undefined behaviour?
question arose if a construct like the following is officially
supported Bash behaviour:
while IFS="" read -d '' -r f ; do
echo "Calling down holy vengance upon $f"
done < <(find "${S}" -type f -print0)
Apparently "read -d ''" or "read -d $'\0'" have some real-world use:
http://unix.stackexchange.com/questions/61029/why-is-0-the-same-as
http://stackoverflow.com/questions/8677546/bash-for-in-looping-on-null-delimited-string-variable
However, according to the documentation:
'-d DELIM'
The first character of DELIM is used to terminate the input
line, rather than newline.
An empty string has no first character, so strictly speaking -d ''
would be undefined behaviour?