Escape dollar sign in environmental variables

envars

#1

One of my project uses environmental variables defined in project settings.
More specifically, I run makefile commands that use env variables. Some of those variables have dollar ($) sign in it. They are single quoted strings (‘asdfadfasdf$0’). I escape those with double dollar ($$) on my machine, but it doesn’t work on CircleCI.

‘$0’ is replaced with ‘bash’,
’$$’ is replaced with ‘11915’

For instance I have in project settings: ENV=‘asd$0’.
In Makefile:

test:
@echo $(ENV)

output: ‘asdbash’

How to?


#2

Escaping with single backslash ($) causes a bug I think, the env variable just disappears when you run the project. With double backslash ‘\$’ I get ‘\bash’.


#3

This is what I ended up with:

docker login -e '$(shell echo $$DOCKER_EMAIL)' -u '$(shell echo $$DOCKER_USER)' -p '$(shell echo $$DOCKER_PASS)'


#4