setup: quote variables in checks

Without "" around the variable, if they are unset, no string is visible
to bash and the test incorrectly passes.
This commit is contained in:
Nishanth Aravamudan 2021-07-09 10:05:51 -05:00 committed by Dr Nic Williams
parent fa5e1dc516
commit cf6cc693aa
1 changed files with 2 additions and 2 deletions

4
setup
View File

@ -48,8 +48,8 @@ initial_settings_yml() {
fi
}
[ -n ${template} ] || usage "ERROR: Missing pipeline template type" 1
[ -d ${target} ] || usage "ERROR: ${target} path not found" 1
[ -n "${template}" ] || usage "ERROR: Missing pipeline template type" 1
[ -d "${target}" ] || usage "ERROR: ${target} path not found" 1
pattern="^($(echo "$pipeline_types" | tr "\n" "|" | sed -e "s/\|*$//"))$"
[[ "${template}"=~$pattern ]] || usage "ERROR: ${template} is not a valid pipeline template" 1