Shell script fails to export the variable
I am trying to export this variable DNA from my local machine, but I am not sure why I keep getting error. I am exporting this because I am working with docker image and want docker to use this variable after exporting this variable from my local machine. What could be the reason it won’t export?
#!/bin/bash
SHELLDROP=0
FULLSM="ADNI_1380^LP6005117-DNA_G04^ADNI_WGS"
export DNA="$(echo "${FULLSM}" | cut -d^ -f2)";
My Docker entrypoint.sh
#!/bin/bash
set -x
quit () {
echo "[$(display_date $(${DATE}))] Run failed at step, exit code: 1"
if [ "${SHELLDROP}" -eq 1 ]; then echo "Dropping to shell"; exec "/bin/bash"; else exit 1; fi
}
if [ -z "${DNA}" ]; then echo "ERROR, must provide DNA in variable ${DNA}"; quit "Job Config"; fi
Error:
+ trap 'echo "[20201109_115710] Terminated by SIGTERM " && sleep 10s' SIGTERM
+ '[' 0 -eq 1 ']'
+ '[' -z 'ADNI_1380^LP6005117-DNA_G04^ADNI_WGS' ']'
+ '[' -z '' ']'
+ echo 'ERROR, must provide DNA in variable ${DNA}'
+ quit 'Job Config'
ERROR, must provide DNA in variable ${DNA}
+++ /bin/date +%s
++ display_date 1604944630
++ /bin/date -d @1604944630 +%Y%m%d_%H%M%S
[20201109_115710] Run failed at Job Config step, exit code: 1
+ echo '[20201109_115710] Run failed at Job Config step, exit code: 1'
+ '[' 0 -eq 1 ']'
+ exit 1
Source: Docker Questions