Skip to content

Commit

Permalink
fix: add error handling for directory changes in scripts
Browse files Browse the repository at this point in the history
- Added '|| exit' to 'cd' commands to handle errors if directory changes fail.
- Improved robustness by preventing potential script failures due to unsuccessful navigation.
  • Loading branch information
RedLeader962 committed Sep 14, 2024
1 parent b55eb17 commit 3ca234d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build_system/ubuntu/lpm_execute_libpointmatcher_unittest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ source "${N2ST_PATH}/import_norlab_shell_script_tools_lib.bash"
# ====Begin========================================================================================
print_formated_script_header 'lpm_execute_libpointmatcher_unittest.bash' ':'

cd "${NBS_LIB_INSTALL_PATH}/${NBS_REPOSITORY_NAME}/build"
cd "${NBS_LIB_INSTALL_PATH}/${NBS_REPOSITORY_NAME}/build" || exit 1

if [[ ${IS_TEAMCITY_RUN} == true ]] || [[ ${TEAMCITY_VERSION} ]]; then
echo -e "##teamcity[testSuiteStarted name='gtest']"
Expand Down Expand Up @@ -68,5 +68,5 @@ fi

print_formated_script_footer 'lpm_execute_libpointmatcher_unittest.bash' ':'
# ====Teardown=====================================================================================
cd "${TMP_CWD}"
cd "${TMP_CWD}" || exit 1
exit $UTEST_EXIT_CODE
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ teamcity_service_msg_blockClosed

print_formated_script_footer "lpm_install_dependencies_general_ubuntu.bash (${IMAGE_ARCH_AND_OS})" "${MSG_LINE_CHAR_INSTALLER}"
# ====Teardown=====================================================================================
cd "${TMP_CWD}"
cd "${TMP_CWD}" || exit
8 changes: 4 additions & 4 deletions build_system/ubuntu/lpm_install_libpointmatcher_ubuntu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ teamcity_service_msg_blockOpened "Install ${NBS_REPOSITORY_NAME}"

mkdir -p "${NBS_LIB_INSTALL_PATH}"
print_msg "Directories (pre libpointmatcher install)$(tree -L 2 "${NBS_LIB_INSTALL_PATH}")"
cd "${NBS_LIB_INSTALL_PATH}"
cd "${NBS_LIB_INSTALL_PATH}" || exit

# ....Repository cloning step......................................................................
if [[ ${BUILD_SYSTEM_CI_INSTALL} == FALSE ]]; then
Expand All @@ -188,7 +188,7 @@ if [[ ${BUILD_SYSTEM_CI_INSTALL} == FALSE ]]; then
git clone https://github.com/"${NBS_REPOSITORY_DOMAIN}"/"${NBS_REPOSITORY_NAME}".git

if [[ "${REPOSITORY_VERSION}" != 'latest' ]]; then
cd "${NBS_REPOSITORY_NAME}"
cd "${NBS_REPOSITORY_NAME}" || exit

git fetch --tags
git tag --list
Expand All @@ -203,7 +203,7 @@ if [[ ${BUILD_SYSTEM_CI_INSTALL} == FALSE ]]; then
fi
fi

cd "${NBS_LIB_INSTALL_PATH}/${NBS_REPOSITORY_NAME}"
cd "${NBS_LIB_INSTALL_PATH}/${NBS_REPOSITORY_NAME}" || exit
mkdir -p build && cd build

# ....Cmake install step...........................................................................
Expand Down Expand Up @@ -279,4 +279,4 @@ fi
print_formated_script_footer "${CALLER_NAME} (${IMAGE_ARCH_AND_OS})" "${MSG_LINE_CHAR_INSTALLER}"

# ====Teardown=====================================================================================
cd "${TMP_CWD}"
cd "${TMP_CWD}" || exit

0 comments on commit 3ca234d

Please sign in to comment.