From 4d6fe3d688a63032cfa0e448af31117b4c004249 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Tue, 12 Apr 2022 11:41:11 -0400 Subject: [PATCH 1/2] Catch unexpected errors in Bourne shell scripts. Check the exit status of commands directly in Bourne shell script. --- .ci/linux-cxx-install.sh | 3 +++ bootstrap.sh | 6 ++++-- src/engine/build.sh | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.ci/linux-cxx-install.sh b/.ci/linux-cxx-install.sh index 1928baa57a..c48dd4a5e6 100755 --- a/.ci/linux-cxx-install.sh +++ b/.ci/linux-cxx-install.sh @@ -5,6 +5,9 @@ # LLVM_VER: The LLVM toolset version to point the repo at. # PACKAGES: Compiler packages to install. +set -e +set -u + if command -v sudo ; then SUDO="sudo -E" fi diff --git a/bootstrap.sh b/bootstrap.sh index fbf577e62d..27a404d1f5 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -7,11 +7,13 @@ # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) +set -e +set -u + # Build b2 echo "Building the B2 engine.." pwd=`pwd` -"${pwd}/src/engine/build.sh" "$@" -if [ $? -ne 0 ]; then +if ! "${pwd}/src/engine/build.sh" "$@" ; then echo echo "Failed to build the B2 engine." 1>&2 exit 1 diff --git a/src/engine/build.sh b/src/engine/build.sh index 0fe8122dfb..ba2d8fb98b 100755 --- a/src/engine/build.sh +++ b/src/engine/build.sh @@ -5,6 +5,9 @@ #~ (See accompanying file LICENSE_1_0.txt or copy at #~ http://www.boost.org/LICENSE_1_0.txt) +set -e +set -u + FALSE=1 TRUE=0 From 12a07c9cfe27fc5a409e715792dcfff219e09c56 Mon Sep 17 00:00:00 2001 From: Thomas Brown Date: Tue, 12 Apr 2022 12:15:11 -0400 Subject: [PATCH 2/2] Remove unnecessary Bourne Again shell handling in Bourne shell. --- src/engine/build.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/engine/build.sh b/src/engine/build.sh index ba2d8fb98b..756a60ffb5 100755 --- a/src/engine/build.sh +++ b/src/engine/build.sh @@ -25,13 +25,7 @@ B2_CXXFLAGS_OPT= # We need to calculate and set SCRIPT_PATH and SCRIPT_DIR to reference this # script so that we can refer to file relative to it. -SCRIPT_PATH="" -if test "${BASH_SOURCE}" ; then - SCRIPT_PATH=${BASH_SOURCE} -fi -if test "${SCRIPT_PATH}" = "" ; then - SCRIPT_PATH=$0 -fi +SCRIPT_PATH=$0 SCRIPT_DIR="$( cd "$( dirname "${SCRIPT_PATH}" )" && pwd )" # This script needs to operate at engine source directory.