Search code examples
bashappveyor

Bash substituting environment variable in command


I am trying to authenticate with GitHub using a password defined in an environment variable in AppVeyor.

The command that I am trying to execute is:

git remote add origin https://username:$EnvPassword@github.com/username/Empty.git

In the above scenario, I want $EnvPassword to be substituted with the password defined in my environment variable.

I thought prefixing with a $ would be enough, but it isn't working at all. I can't seem to find anything about it anywhere else online.


Solution

  • Try replacing $EnvPassword with the more robust version ${EnvPassword}. This type of substitution is usually better for complex commands.

    git remote add origin https://username:${EnvPassword}@github.com/username/Empty.git