Ok, this isn't the usual bash "command not found" question.
I have a generated environment file I build up with some bash scripting, then pass it into a docker-compose service definition. The file contains a couple of variables with single quotes and spaces in the values. Docker and my entrypoint script don't seem to mind, but I source the generated file in my script to create a couple of related files (update a properties file with some values) and when I source it I get "command not found" when those troublesome variables are read.
Here's a sample env file:
TEST1=Hi
TEST2=['top','bottom']
TEST3=Bye
TEST4=Hi Bye
When I try sourcing it, bash/shell tries to execute/eval "Bye" as if it was a call to set a variable before calling a command:
$ source ./test.env
bash: Bye: command not found...
Is there way to import the variables without this evaluation?
Before you say it, I can't quote or escape these values like you might in normal bash. The generated file values work fine for docker and the node.js service running inside. I've found that trying different combination of quoting and escaping will work for bash but not node.js, etc...
For example if I double quote TEST4="Hi Bye"
bash will be happy, but in my server.js when I process.env["TEST4"] the string contains the double quotes and they're impossible to remove, but when I use the variable the unwanted quotes are in there. Escaping \ also causes my problems because I have to actively read and replace them.
I just want bash sourcing to skip evaluation, or find another way to import the variables from file into a script. Any suggestions? Thanks.