Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quoting issue in the last eval statement in set_var; also check for invalid variable names #174

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading