Skip to content

Commit 31b3891

Browse files
committed
cukinia: fix handling of default config file
A regression was introduced in 6ef4a08 where the default config file would stop being evaluated. This reworks the logic a bit to revert to the intended behaviour, and while we're here, clarify variables a bit.
1 parent c1d6d31 commit 31b3891

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

cukinia

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
CUKINIA_VERSION="0.8.1-dev"
1111

1212
# Default configuration file
13-
CUKINIA_CONF='/etc/cukinia/cukinia.conf'
13+
DEFAULT_CONFIG_FILE='/etc/cukinia/cukinia.conf'
1414

1515
# Generic user functions templated to _cukinia_xxx()
1616
GENERIC_FUNCTS='cmd
@@ -161,13 +161,23 @@ junitxml)
161161
;;
162162
esac
163163

164-
# Take config file as first trailing argument
165-
CUKINIA_CONF="$1"
166-
if [ "$(dirname "$CUKINIA_CONF")" = "." ]; then
167-
CUKINIA_CONF="./$CUKINIA_CONF"
164+
# Read config from optional 1st trailing argument
165+
if [ -z "$1" ]; then
166+
config_file="$DEFAULT_CONFIG_FILE"
167+
else
168+
if [ ! -r "$1" ]; then
169+
echo "Fatal: cannot read specified config file ($1)"
170+
exit 1
171+
fi
172+
173+
config_file="$1"
174+
fi
175+
176+
if [ "$(dirname "$config_file")" = "." ]; then
177+
config_file="./$config_file"
168178
fi
169179

170-
# Use this file to override default config
180+
# Use this file to override default environment/variables
171181
if [ -r /etc/default/cukinia ]; then
172182
. /etc/default/cukinia
173183
fi
@@ -1483,7 +1493,7 @@ done
14831493
cukinia_tests=0
14841494
cukinia_failures=0
14851495
cukinia_skip=0
1486-
cukinia_conf_include "$CUKINIA_CONF"
1496+
cukinia_conf_include "$config_file"
14871497

14881498
# Finish logging
14891499
case "$__log_format" in

0 commit comments

Comments
 (0)