From 5d0acf20f88b1820cb8b641cfc5a43e973122701 Mon Sep 17 00:00:00 2001 From: happysalada Date: Tue, 3 Aug 2021 11:07:58 +0900 Subject: [PATCH] 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) --- pkgs/stdenv/generic/setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 2a1e0cfc6de3..dbe60787ee13 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -716,9 +716,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