forked from magefile/mage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow escaping "$" in command arguments
The `sh.Exec` family of functions used to use `os.Expand` to expand environment variables in command arguments, but that function offers no escape syntax -- no way to avoid expanding dollar signs that the caller really wants to include on the command line. This commit implements a new, mostly compatible `Expand` function to allow escaping the environment-variable syntax, plus an accompanying `Escape` function to producing escaped strings. This technically breaks backward compatibility; any existing code that has used the sequence "\\" or "\$" in its command arguments will need to be updated. Although the compatibility argument prevents `os.Expand` from changing, documentation for `sh.Exec` hasn't actually stated that it follows all the same rules as `os.Expand`, so it's possible to view this change as merely a bugfix, formalizing a new syntax that had not previously been established. Fixes magefile#434
- Loading branch information
Showing
2 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters