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

Commit

Permalink
escape single-quote and double-quote characters in environment
Browse files Browse the repository at this point in the history
  • Loading branch information
edquist committed May 9, 2019
1 parent 6294ef0 commit d42bd80
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scripts/condor_submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,14 @@ if [ "x$environment" != "x" ] ; then
# new condor format to avoid errors when things like LS_COLORS (which
# has semicolons in it) get captured
eval "env_array=($environment)"
sq="'" # map key=val -> key='val'
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
Expand Down

0 comments on commit d42bd80

Please # to comment.