From 9a9c2e65791d8f8a07b2b3b1555f633d47520197 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 21 Feb 2018 11:56:06 +0300 Subject: [PATCH] cc-wrapper: fix bool handling for empty and zero values Before the code would fail silently for zero values and with some output for empties. We now currently handle both via defaulting value to zero and making `let` return success error code when there's no syntax error. --- pkgs/build-support/cc-wrapper/utils.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/cc-wrapper/utils.sh b/pkgs/build-support/cc-wrapper/utils.sh index 4b2b1380918..9215fe2dc39 100644 --- a/pkgs/build-support/cc-wrapper/utils.sh +++ b/pkgs/build-support/cc-wrapper/utils.sh @@ -25,7 +25,11 @@ mangleVarBool() { for infix in "${role_infixes[@]}"; do local inputVar="${var/+/${infix}}" if [ -v "$inputVar" ]; then - let "${outputVar} |= ${!inputVar}" + # "1" in the end makes `let` return success error code when + # expression itself evaluates to zero. + # We don't use `|| true` because that would silence actual + # syntax errors from bad variable values. + let "${outputVar} |= ${!inputVar:-0}" "1" fi done }