Big picture of the issue: I'm creating Golang script (http://github.com/Droplr/aws-env) that will be used to secure retrieve environment variables and export them to be used for another process.
As we know, it's not easy doable as script can't export vars outside [1], [2].
So the way we were trying to do it, is basically outputing export statements and then using bash backticks to run that command.
Final usage is like:
`aws-env` && printenv
where printenv should show variables exported by evaluated aws-env output (which contains "export" statements).
The problem arises with variables that contain spaces/new lines etc.
Simplifying underline code, this one works:
$ export A=b\ b
$ printenv | grep A=
A=b b
And this - not:
$ `echo export A=b\ b`
$ printenv | grep A=
A=b
I've went over other Stackoverflow discussions ([3]) but couldn't find clear answer for that problem (mostly the answer is to not use backticks, but with our overall problem we try to solve it wont be so easy...)