From 27b758b4a0dd8327752aa5a46dd1c4c2f4bc02ef Mon Sep 17 00:00:00 2001 From: Matthias Krack Date: Thu, 22 Jan 2026 17:28:20 +0100 Subject: [PATCH] Retrieve error code via PIPESTATUS --- make_cp2k.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/make_cp2k.sh b/make_cp2k.sh index 5e31fe53cb..4785d2aae9 100755 --- a/make_cp2k.sh +++ b/make_cp2k.sh @@ -536,14 +536,18 @@ fi # CMake build step echo -e '\n*** Compiling CP2K ***\n' -if ! cmake --build "${CMAKE_BUILD_PATH}" --parallel "${NUM_PROCS}" -- "${VERBOSE_FLAG}" |& tee "${CMAKE_BUILD_PATH}/ninja.log"; then +cmake --build "${CMAKE_BUILD_PATH}" --parallel "${NUM_PROCS}" -- "${VERBOSE_FLAG}" |& tee "${CMAKE_BUILD_PATH}"/ninja.log +EXIT_CODE=${PIPESTATUS[0]} +if ((EXIT_CODE != 0)); then echo "ERROR: The CMake build step failed with the error code ${EXIT_CODE}" ${EXIT_CMD} "${EXIT_CODE}" fi # CMake install step echo -e '\n*** Installing CP2K ***\n' -if ! cmake --install "${CMAKE_BUILD_PATH}" |& tee "${CMAKE_BUILD_PATH}/install.log"; then +cmake --install "${CMAKE_BUILD_PATH}" |& tee "${CMAKE_BUILD_PATH}"/install.log +EXIT_CODE=${PIPESTATUS[0]} +if ((EXIT_CODE != 0)); then echo "ERROR: The CMake installation step failed with the error code ${EXIT_CODE}" ${EXIT_CMD} "${EXIT_CODE}" fi