Skip to content

Commit

Permalink
Run build env in bash strict mode
Browse files Browse the repository at this point in the history
The ./lib/env_san.sh source would fail because the relative path is not found
from the build directory.

But the error was not caught because the ``eval`` only returned the last
statements exit code.
  • Loading branch information
ChillerDragon committed Nov 12, 2024
1 parent 3fbd094 commit 79c24d2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_patches="$(get_applied_git_patches)"
run_cmd="$CFG_ENV_RUNTIME gdb -ex='handle SIGPIPE nostop noprint pass' -ex=run --args ./\"$CFG_BIN\" \"exec autoexec.cfg;logfile $logfile;#sid:$SERVER_UUID\""
log "$run_cmd"
launch_commit="$(get_commit)"
eval "$run_cmd"
bash -c "set -euo pipefail;$run_cmd"
log "build commit: $launch_commit"
if [ "$git_patches" != "" ]
then
Expand Down
2 changes: 1 addition & 1 deletion lib/exec_all_servers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ do
figlet "$d"
echo -e "navigating to: \\033[1m$(pwd)\\033[0m"
echo -e "executing: \\033[1m$shell_command\\033[0m"
eval "$shell_command" || handle_error
bash -c "set -euo pipefail;$shell_command" || handle_error
)
done

2 changes: 1 addition & 1 deletion lib/include/update/bam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function bam_update_teeworlds() {

apply_git_patches
local build_cmd="$CFG_BAM_BIN ${arg_bam_flags[*]}"
eval "$build_cmd" || \
bash -c "set -euo pipefail;$build_cmd" || \
{ err --log "build failed (bam)"; }
reverse_git_patches

Expand Down
4 changes: 2 additions & 2 deletions lib/include/update/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ function cmake_update() {
local build_fail=0
local build_cmd="$CFG_ENV_BUILD cmake .. ${arg_cmake_flags[*]}"
log "$(tput bold)$build_cmd$(tput sgr0)"
eval "$build_cmd" || \
{ err --log "build failed at $branch $bin_commit (cmake)"; build_fail=1; }
bash -c "set -euo pipefail;$build_cmd" || \
{ err --log "build failed at $branch $bin_commit (cmake)"; err "build directory: $PWD";build_fail=1; }
if [ "$build_fail" == "0" ]
then
make "-j$(get_cores)" || { err --log "build failed at $branch $(git rev-parse HEAD) (make)"; build_fail=1; }
Expand Down
6 changes: 4 additions & 2 deletions lib/include/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ def_var 'CFG_GIT_BRANCH' 'git_branch' "" ''
def_var 'CFG_SERVER_TYPE' 'server_type' "teeworlds" '(tem|teeworlds)'
def_var 'CFG_TEM_SETTINGS' 'tem_settings' "tem.settings" ''
def_var 'CFG_TEM_PATH' 'tem_path' "/home/$USER/git/TeeworldsEconMod" ''
def_var 'CFG_ENV_BUILD' 'env_build' "source ./lib/env_san.sh;" '(.*=.*|.*;$|)'
def_var 'CFG_ENV_RUNTIME' 'env_runtime' "source ./lib/env_san.sh;" '(.*=.*|.*;$|)'
# shellcheck disable=SC2016
def_var 'CFG_ENV_BUILD' 'env_build' 'source $SCRIPT_ROOT/lib/env_san.sh;' '(.*=.*|.*;$|)'
# shellcheck disable=SC2016
def_var 'CFG_ENV_RUNTIME' 'env_runtime' 'source $SCRIPT_ROOT/lib/env_san.sh;' '(.*=.*|.*;$|)'
def_var 'CFG_LOG_EXT' 'logfile_extension' ".log" ''
def_var 'CFG_AUTO_CLEANUP_OLD_LOCAL_DATA' 'auto_cleanup_old_local_data' "0" '(0|no|off|false|1|yes|on|true)'
def_var 'CFG_GITPATH_ANTIBOT' 'gitpath_antibot' "" ''
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ else # teeworlds
tput bold
echo "$run_cmd"
tput sgr0
eval "$run_cmd"
bash -c "set -euo pipefail;$run_cmd"

if [ "$arg_logs" == "1" ] && [ "$arg_is_interactive" == "0" ]
then
Expand Down

0 comments on commit 79c24d2

Please sign in to comment.