(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestShellEscapeArg(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | input string |
| 14 | expected string |
| 15 | }{ |
| 16 | { |
| 17 | name: "simple argument without special characters", |
| 18 | input: "hello", |
| 19 | expected: "hello", |
| 20 | }, |
| 21 | { |
| 22 | name: "argument with parentheses", |
| 23 | input: "shell(git add:*)", |
| 24 | expected: "'shell(git add:*)'", |
| 25 | }, |
| 26 | { |
| 27 | name: "argument with brackets", |
| 28 | input: "pattern[abc]", |
| 29 | expected: "'pattern[abc]'", |
| 30 | }, |
| 31 | { |
| 32 | name: "argument with spaces", |
| 33 | input: "hello world", |
| 34 | expected: "'hello world'", |
| 35 | }, |
| 36 | { |
| 37 | name: "argument with single quote", |
| 38 | input: "don't", |
| 39 | expected: "'don'\\''t'", |
| 40 | }, |
| 41 | { |
| 42 | name: "argument with asterisk", |
| 43 | input: "*.txt", |
| 44 | expected: "'*.txt'", |
| 45 | }, |
| 46 | { |
| 47 | name: "argument with dollar sign", |
| 48 | input: "$HOME", |
| 49 | expected: "'$HOME'", |
| 50 | }, |
| 51 | { |
| 52 | name: "simple flag", |
| 53 | input: "--allow-tool", |
| 54 | expected: "--allow-tool", |
| 55 | }, |
| 56 | { |
| 57 | name: "already double-quoted argument is now properly escaped", |
| 58 | input: "\"$INSTRUCTION\"", |
| 59 | expected: "'\"$INSTRUCTION\"'", |
| 60 | }, |
| 61 | { |
| 62 | name: "already single-quoted argument is now properly escaped", |
| 63 | input: "'hello world'", |
| 64 | expected: "''\\''hello world'\\'''", |
| 65 | }, |
| 66 | { |
| 67 | name: "partial double quote should be escaped", |
nothing calls this directly
no test coverage detected