From 57b732b602e7f5357fc87d3d530d7a4b14362c93 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Sat, 10 Oct 2026 12:28:07 +0200 Subject: [PATCH] fix: Don't double backslashes in shellQuote --- internal/cmd/shellquote.go | 8 +------- internal/cmd/shellquote_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 9 deletions(-) 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`,