stdenv/setup.sh: fix read -N 0 for bash 5

somehow `read -N 0` behavior changed in bash 5. `read -d ''` has identical behavior
the purpose of the function is to read stdin and exit 1 on a null byte (i.e. if stdin is the content of a binary)

(cherry picked from commit 5d0acf20f8)
This commit is contained in:
happysalada 2021-08-03 11:07:58 +09:00 committed by Raphael Megzari
parent 8bc930ca39
commit 33518fcb45

View File

@ -736,9 +736,11 @@ substituteStream() {
printf "%s" "${!var}"
}
# put the content of a file in a variable
# fail loudly if provided with a binary (containing null bytes)
consumeEntire() {
# read returns non-0 on EOF, so we want read to fail
if IFS='' read -r -N 0 $1; then
if IFS='' read -r -d '' $1 ; then
echo "consumeEntire(): ERROR: Input null bytes, won't process" >&2
return 1
fi