Skip to content

Commit

Permalink
Merge pull request #79 from edquist/new-condor-env-format
Browse files Browse the repository at this point in the history
New condor env format (SOFTWARE-3589)
  • Loading branch information
edquist authored May 10, 2019
2 parents b709684 + d42bd80 commit 81de825
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/scripts/condor_submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,18 @@ submit_file_environment="#"

if [ "x$environment" != "x" ] ; then
# Input format is suitable for bourne shell style assignment. Convert to
# old condor format (no double quotes in submit file).
# FIXME: probably it's better to convert everything into the 'new' Condor
# environment format.
# new condor format to avoid errors when things like LS_COLORS (which
# has semicolons in it) get captured
eval "env_array=($environment)"
submit_file_environment=""
for env_var in "${env_array[@]}"; do
if [ "x$submit_file_environment" == "x" ] ; then
submit_file_environment="environment = "
else
submit_file_environment="$submit_file_environment;"
fi
submit_file_environment="${submit_file_environment}${env_var}"
done
dq='"'
sq="'"
# map key=val -> key='val'
env_array=("${env_array[@]/=/=$sq}")
env_array=("${env_array[@]/%/$sq}")
# escape single-quote and double-quote characters (by doubling them)
env_array=("${env_array[@]//$sq/$sq$sq}")
env_array=("${env_array[@]//$dq/$dq$dq}")
submit_file_environment="environment = \"${env_array[*]}\""
else
if [ "x$envir" != "x" ] ; then
# Old Condor format (no double quotes in submit file)
Expand Down

0 comments on commit 81de825

Please sign in to comment.