Skip to content
This repository was archived by the owner on Oct 10, 2019. It is now read-only.

Commit 81de825

Browse files
authored
Merge pull request #79 from edquist/new-condor-env-format
New condor env format (SOFTWARE-3589)
2 parents b709684 + d42bd80 commit 81de825

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/scripts/condor_submit.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,18 @@ submit_file_environment="#"
201201

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

0 commit comments

Comments
 (0)