Skip to content

Commit

Permalink
Fix quoting issue in the last eval statement in set_var; also check f…
Browse files Browse the repository at this point in the history
…or invalid variable names

Don't add extra quoting to the setting of the default value -- that
causes disconnection issues for some reason
  • Loading branch information
matyasselmeci committed Aug 12, 2024
1 parent accd444 commit 17657cc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions 10-setup-htcondor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ set_var() {
if [ -z "$var_name" ]; then
# empty line
return 0
elif [[ ! $var_name =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
printf "Skipping invalid variable name '%s'\n" "$var_name" 1>&2
if [[ $var_req == Y ]]; then
# probably never happens but just in case...
printf "Variable named '%s' was required; exiting\n" "$var_name" 1>&2
exit 1
fi
return 0
fi

var_name_len=${#var_name}
Expand All @@ -38,6 +46,7 @@ set_var() {
# no default, do not set
return 0
else
# Adding extra quoting here caused startd disconnection issues for some reason
eval var_val=$var_def
fi
fi
Expand Down Expand Up @@ -80,8 +89,10 @@ set_var() {
fi
fi

# define it for future use
eval "$var_name='$var_val'"
# define it for future use; make sure it's properly quoted
local statement="$(printf "%q=%q" "$var_name" "$var_val")"
echo "setting var: $statement"
eval "$statement"
return 0
}

Expand Down

0 comments on commit 17657cc

Please sign in to comment.