diff --git a/internal/cmd/shellquote.go b/internal/cmd/shellquote.go index 95e3fd4..f320518 100644 --- a/internal/cmd/shellquote.go +++ b/internal/cmd/shellquote.go @@ -24,18 +24,12 @@ func shellQuote(s string) string { inSingleQuotes := false for _, b := range []byte(s) { switch b { - case backslash: - if !inSingleQuotes { - result = append(result, singleQuote) - inSingleQuotes = true - } - result = append(result, backslash, backslash) case singleQuote: if inSingleQuotes { result = append(result, singleQuote) inSingleQuotes = false } - result = append(result, '\\', singleQuote) + result = append(result, backslash, singleQuote) default: if !inSingleQuotes { result = append(result, singleQuote) diff --git a/internal/cmd/shellquote_test.go b/internal/cmd/shellquote_test.go index 8586209..6b8d675 100644 --- a/internal/cmd/shellquote_test.go +++ b/internal/cmd/shellquote_test.go @@ -14,8 +14,10 @@ func TestShellQuote(t *testing.T) { `'`: `\'`, `''`: `\'\'`, `'a'`: `\''a'\'`, - `\`: `'\\'`, - `\a`: `'\\a'`, + `\`: `'\'`, + `\'`: `'\'\'`, + `\a`: `'\a'`, + `\n`: `'\n'`, `$a`: `'$a'`, `a`: `a`, `a/b`: `a/b`,