Make sure the getValue method returns the default value if the file is missing

This commit is contained in:
Jason M. Wood 2014-08-26 19:22:55 -06:00
parent b84b0b7783
commit 1166006879

View File

@ -470,11 +470,12 @@ getValue() {
# Find the key/value combo.
KEY=$($PERL -ne 'if ($_ =~ /^('$2')=.*$/i) { print lc $1; }' $1)
VALUE=$($PERL -ne 'if ($_ =~ /^'$2'=(.*)$/i) { print $1; }' $1)
if [ -n "$KEY" ] && [ -n "$VALUE" ]; then
echo "$VALUE"
else
echo "$3"
fi
fi
# Return the value if found, the default value if not.
if [ -n "$KEY" ] && [ -n "$VALUE" ]; then
echo "$VALUE"
else
echo "$3"
fi
}