Skip to content

Commit

Permalink
Don't quote shell args just because of equals signs
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Dec 13, 2019
1 parent 871fb53 commit 91e562a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/chezmoi/maybeshellquote.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
)

var needShellQuoteRegexp = regexp.MustCompile(`[^+\-./0-9A-Z_a-z]`)
var needShellQuoteRegexp = regexp.MustCompile(`[^+\-./0-9=A-Z_a-z]`)

const (
backslash = '\\'
Expand Down
22 changes: 12 additions & 10 deletions internal/chezmoi/maybeshellquote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import (

func TestMaybeShellQuote(t *testing.T) {
for s, expected := range map[string]string{
``: `''`,
`'`: `\'`,
`''`: `\'\'`,
`'a'`: `\''a'\'`,
`\`: `'\\'`,
`\a`: `'\\a'`,
`$a`: `'$a'`,
`a`: `a`,
`a/b`: `a/b`,
`a b`: `'a b'`,
``: `''`,
`'`: `\'`,
`''`: `\'\'`,
`'a'`: `\''a'\'`,
`\`: `'\\'`,
`\a`: `'\\a'`,
`$a`: `'$a'`,
`a`: `a`,
`a/b`: `a/b`,
`a b`: `'a b'`,
`--arg`: `--arg`,
`--arg=value`: `--arg=value`,
} {
assert.Equal(t, expected, MaybeShellQuote(s), "quoting %q", s)
}
Expand Down

0 comments on commit 91e562a

Please sign in to comment.