Skip to content

Commit

Permalink
Fix error that compiled.cfg does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Nov 12, 2024
1 parent 79c24d2 commit 924d801
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/include/tw_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ function get_tw_config_value() {
printf '%s' "$value" | sed -e 's/[[:space:]]*$//'
}

function compile_tw_config() {
twcfg.include_exec "autoexec.cfg" > lib/tmp/compiled.cfg
}

function get_tw_config() {
if [ "$#" != "2" ]
then
Expand All @@ -304,7 +308,7 @@ function get_tw_config() {
fi
mkdir -p lib/tmp
twcfg_line=0
twcfg.include_exec "autoexec.cfg" > lib/tmp/compiled.cfg
compile_tw_config
found_key="$(grep "^$config_key " lib/tmp/compiled.cfg | tail -n1 | cut -d' ' -f2- | xargs)"
if [ "$found_key" == "" ]
then
Expand Down
11 changes: 10 additions & 1 deletion lib/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,16 @@ function check_warnings() {
wrn ""
fi
fi
port="$(wc -l < <(grep '^sv_port ' lib/tmp/compiled.cfg))"
# make sure the grep does not fail to open the non existent file
if [ ! -f lib/tmp/compiled.cfg ]
then
compile_tw_config
fi
if ! port="$(wc -l < <(grep '^sv_port ' lib/tmp/compiled.cfg))"
then
wrn "WARNING: failed to count ports in compiled.cfg"
wrn " file should be at $PWD/lib/tmp/compiled.cfg"
fi
if [ "$port" != "" ] && [ "$port" -gt "1" ]
then
wrn "WARNING: found sv_port $port times in your config"
Expand Down

0 comments on commit 924d801

Please sign in to comment.