Skip to content

Commit 924d801

Browse files
committed
Fix error that compiled.cfg does not exist
1 parent 79c24d2 commit 924d801

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

lib/include/tw_config.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ function get_tw_config_value() {
283283
printf '%s' "$value" | sed -e 's/[[:space:]]*$//'
284284
}
285285

286+
function compile_tw_config() {
287+
twcfg.include_exec "autoexec.cfg" > lib/tmp/compiled.cfg
288+
}
289+
286290
function get_tw_config() {
287291
if [ "$#" != "2" ]
288292
then
@@ -304,7 +308,7 @@ function get_tw_config() {
304308
fi
305309
mkdir -p lib/tmp
306310
twcfg_line=0
307-
twcfg.include_exec "autoexec.cfg" > lib/tmp/compiled.cfg
311+
compile_tw_config
308312
found_key="$(grep "^$config_key " lib/tmp/compiled.cfg | tail -n1 | cut -d' ' -f2- | xargs)"
309313
if [ "$found_key" == "" ]
310314
then

lib/lib.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,16 @@ function check_warnings() {
277277
wrn ""
278278
fi
279279
fi
280-
port="$(wc -l < <(grep '^sv_port ' lib/tmp/compiled.cfg))"
280+
# make sure the grep does not fail to open the non existent file
281+
if [ ! -f lib/tmp/compiled.cfg ]
282+
then
283+
compile_tw_config
284+
fi
285+
if ! port="$(wc -l < <(grep '^sv_port ' lib/tmp/compiled.cfg))"
286+
then
287+
wrn "WARNING: failed to count ports in compiled.cfg"
288+
wrn " file should be at $PWD/lib/tmp/compiled.cfg"
289+
fi
281290
if [ "$port" != "" ] && [ "$port" -gt "1" ]
282291
then
283292
wrn "WARNING: found sv_port $port times in your config"

0 commit comments

Comments
 (0)