Open hborham opened 1 year ago
Similar problem here. I am calling sh.Exec with a list of arguments one of which contains $. I want the literal $ but mage tries to expand it and I found no way to prevent this.
I've just submitted a PR that I think would solve this. But @hborham, note that for your example to work the way you want, you'd need to remove the apostrophes from your arguments. Apostrophes are one way to avoid having the shell expand environment variables. In doing so, the shell would strip the apostrophes from the argument prior to invoking the given command, so pact-broker
would receive literally --user=admin:${user.bitbucketAppPassword}
as its argument. Using my PR, you might write code like this:
sh.Run("pact-broker", "create-webhook", sh.Escape("--user=admin:${user.bitbucketAppPassword}"))
Within the
sh
package, args are being expanded in the case where normal sh command would not expand args within single quotes. Example command:pact-broker create-webhook --user='admin:${user.bitbucketAppPassword}'
${user.bitbucketAppPassword}
pact-broker create-webhook --user='admin:'
https://github.com/magefile/mage/blob/26cdb5c7369a9b03981eb906dd3606c566e45c16/sh/cmd.go#L92-L115