I'm trying to source a multiline associative array like this
declare -p -A MOCK_RETURNS=(
['/usr/local/bin/docker']=""
['/usr/local/bin/docker history']="IMAGE CREATED AT CREATED BY SIZE COMMENT
cf0f3ca922e0 -10-18T20:48:51+02:00 /bin/sh -c #(nop) CMD ['/bin/bash'] 0
<missing> 2019-10-18T20:48:51+02:00 /bin/sh -c mkdir -p /run/systemd && echo 'do… 7"
) > mockResponse
---- other file
source mockResponse
echo ${MOCK_RETURNS['/usr/local/bin/docker history']}
keeping the linebreaks in the /usr/local/bin/docker history
-value in bash.
Sadly it seems to be sourced as one line.
I already tried echoing it like
echo "declare -A MOCK_RETURNS=(
['/usr/local/bin/docker']=\"\"
['/usr/local/bin/docker history']=\"IMAGE CREATED AT CREATED BY SIZE COMMENT
cf0f3ca922e0 $nextYear-10-18T20:48:51+02:00 /bin/sh -c #(nop) CMD ['/bin/bash'] 0
<missing> 2019-10-18T20:48:51+02:00 /bin/sh -c mkdir -p /run/systemd && echo 'do… 7\"
)" > mockReturns
---- other file
source mockResponse
echo ${MOCK_RETURNS['/usr/local/bin/docker history']}
Which keeps shows the line breaks in the mockReturns
file, but when I source it, they're gone again.