Skip to content

Commit 2d17132

Browse files
committed
Handle shellshape list subcommand in normalizer
1 parent c40c8dc commit 2d17132

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

handlers/shellshape.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ func init() {
77
}
88

99
// handleShellshape handles the shellshape command itself.
10-
// All positional arguments are the input command being analyzed,
10+
// "list" subcommand is kept structural (no args to normalize).
11+
// All other positional arguments are the input command being analyzed,
1112
// so they collapse to a single <command> placeholder. Subshells are preserved.
1213
func handleShellshape(subcommand string, tokens []string) []string {
1314
args, redirects := shellshape.SplitRedirects(tokens)
1415

16+
// "list" subcommand has no args to normalize.
17+
if len(args) > 0 && args[0] == "list" {
18+
return append([]string{"list"}, redirects...)
19+
}
20+
1521
var result []string
1622
hasPositional := false
1723

handlers/shellshape_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ func TestShellshape(t *testing.T) {
2121
{"command with pipes as single arg", `shellshape 'echo hello | grep h'`, "shellshape <command>"},
2222
{"multiple words", "shellshape docker run -it ubuntu bash", "shellshape <command>"},
2323

24+
// List subcommand
25+
{"list subcommand", "shellshape list", "shellshape list"},
26+
2427
// With redirect
2528
{"with redirect", "shellshape echo hi > /tmp/out.txt", "shellshape <command> > <path>"},
2629
}

0 commit comments

Comments
 (0)