From 91e562a660a0dc90796bd78fceca1a4705cda74d Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 13 Dec 2019 14:58:24 +0100 Subject: [PATCH] Don't quote shell args just because of equals signs --- internal/chezmoi/maybeshellquote.go | 2 +- internal/chezmoi/maybeshellquote_test.go | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/chezmoi/maybeshellquote.go b/internal/chezmoi/maybeshellquote.go index 2491086f41e..6d527d16fe3 100644 --- a/internal/chezmoi/maybeshellquote.go +++ b/internal/chezmoi/maybeshellquote.go @@ -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 = '\\' diff --git a/internal/chezmoi/maybeshellquote_test.go b/internal/chezmoi/maybeshellquote_test.go index 30c2dbc16fb..cb145721cc0 100644 --- a/internal/chezmoi/maybeshellquote_test.go +++ b/internal/chezmoi/maybeshellquote_test.go @@ -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) }