Skip to content

Commit 79c24d2

Browse files
committed
Run build env in bash strict mode
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.
1 parent 3fbd094 commit 79c24d2

6 files changed

Lines changed: 10 additions & 8 deletions

File tree

gdb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ git_patches="$(get_applied_git_patches)"
3636
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\""
3737
log "$run_cmd"
3838
launch_commit="$(get_commit)"
39-
eval "$run_cmd"
39+
bash -c "set -euo pipefail;$run_cmd"
4040
log "build commit: $launch_commit"
4141
if [ "$git_patches" != "" ]
4242
then

lib/exec_all_servers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ do
105105
figlet "$d"
106106
echo -e "navigating to: \\033[1m$(pwd)\\033[0m"
107107
echo -e "executing: \\033[1m$shell_command\\033[0m"
108-
eval "$shell_command" || handle_error
108+
bash -c "set -euo pipefail;$shell_command" || handle_error
109109
)
110110
done
111111

lib/include/update/bam.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function bam_update_teeworlds() {
4848

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

lib/include/update/cmake.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ function cmake_update() {
203203
local build_fail=0
204204
local build_cmd="$CFG_ENV_BUILD cmake .. ${arg_cmake_flags[*]}"
205205
log "$(tput bold)$build_cmd$(tput sgr0)"
206-
eval "$build_cmd" || \
207-
{ err --log "build failed at $branch $bin_commit (cmake)"; build_fail=1; }
206+
bash -c "set -euo pipefail;$build_cmd" || \
207+
{ err --log "build failed at $branch $bin_commit (cmake)"; err "build directory: $PWD";build_fail=1; }
208208
if [ "$build_fail" == "0" ]
209209
then
210210
make "-j$(get_cores)" || { err --log "build failed at $branch $(git rev-parse HEAD) (make)"; build_fail=1; }

lib/include/vars.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def_var 'CFG_GIT_BRANCH' 'git_branch' "" ''
2626
def_var 'CFG_SERVER_TYPE' 'server_type' "teeworlds" '(tem|teeworlds)'
2727
def_var 'CFG_TEM_SETTINGS' 'tem_settings' "tem.settings" ''
2828
def_var 'CFG_TEM_PATH' 'tem_path' "/home/$USER/git/TeeworldsEconMod" ''
29-
def_var 'CFG_ENV_BUILD' 'env_build' "source ./lib/env_san.sh;" '(.*=.*|.*;$|)'
30-
def_var 'CFG_ENV_RUNTIME' 'env_runtime' "source ./lib/env_san.sh;" '(.*=.*|.*;$|)'
29+
# shellcheck disable=SC2016
30+
def_var 'CFG_ENV_BUILD' 'env_build' 'source $SCRIPT_ROOT/lib/env_san.sh;' '(.*=.*|.*;$|)'
31+
# shellcheck disable=SC2016
32+
def_var 'CFG_ENV_RUNTIME' 'env_runtime' 'source $SCRIPT_ROOT/lib/env_san.sh;' '(.*=.*|.*;$|)'
3133
def_var 'CFG_LOG_EXT' 'logfile_extension' ".log" ''
3234
def_var 'CFG_AUTO_CLEANUP_OLD_LOCAL_DATA' 'auto_cleanup_old_local_data' "0" '(0|no|off|false|1|yes|on|true)'
3335
def_var 'CFG_GITPATH_ANTIBOT' 'gitpath_antibot' "" ''

start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ else # teeworlds
127127
tput bold
128128
echo "$run_cmd"
129129
tput sgr0
130-
eval "$run_cmd"
130+
bash -c "set -euo pipefail;$run_cmd"
131131

132132
if [ "$arg_logs" == "1" ] && [ "$arg_is_interactive" == "0" ]
133133
then

0 commit comments

Comments
 (0)