claudetool: minor auto-install cleanup
Follow-up to 495c1fa247565e21b36bcb847c6cd3f08e0e196f
diff --git a/claudetool/bash.go b/claudetool/bash.go
index 43659b8..39914c6 100644
--- a/claudetool/bash.go
+++ b/claudetool/bash.go
@@ -363,19 +363,6 @@
return nil
}
-// commandExists checks if a command exists using exec.LookPath
-func commandExists(command string) bool {
- // If it's an absolute or relative path, check if the file exists
- if strings.Contains(command, "/") {
- _, err := os.Stat(command)
- return err == nil
- }
-
- // Otherwise, use exec.LookPath to find it in PATH
- _, err := exec.LookPath(command)
- return err == nil
-}
-
// Command safety check cache to avoid repeated LLM calls
var (
autoInstallMu sync.Mutex
diff --git a/claudetool/bashkit/parsing.go b/claudetool/bashkit/parsing.go
index 2b17ae3..df37ab8 100644
--- a/claudetool/bashkit/parsing.go
+++ b/claudetool/bashkit/parsing.go
@@ -4,6 +4,7 @@
"fmt"
"strings"
+ "mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
)
@@ -52,7 +53,7 @@
// commands with slashes are user-specified executables/scripts
return true
}
- if isBuiltin(cmdName) {
+ if interp.IsBuiltin(cmdName) {
return true
}
if !seen[cmdName] {
@@ -64,19 +65,3 @@
return commands, nil
}
-
-// isBuiltin checks if a command is a shell built-in using the same logic as mvdan.cc/sh/v3/interp
-// This is copied from mvdan.cc/sh/v3/interp.isBuiltin since it's not exported
-// See https://github.com/mvdan/sh/issues/1164
-func isBuiltin(name string) bool {
- switch name {
- case "true", ":", "false", "exit", "set", "shift", "unset",
- "echo", "printf", "break", "continue", "pwd", "cd",
- "wait", "builtin", "trap", "type", "source", ".", "command",
- "dirs", "pushd", "popd", "umask", "alias", "unalias",
- "fg", "bg", "getopts", "eval", "test", "[", "exec",
- "return", "read", "mapfile", "readarray", "shopt":
- return true
- }
- return false
-}
diff --git a/claudetool/bashkit/parsing_test.go b/claudetool/bashkit/parsing_test.go
index 9a2b831..40e1bb0 100644
--- a/claudetool/bashkit/parsing_test.go
+++ b/claudetool/bashkit/parsing_test.go
@@ -80,32 +80,6 @@
}
}
-func TestIsBuiltin(t *testing.T) {
- tests := []struct {
- name string
- command string
- expected bool
- }{
- {"echo is builtin", "echo", true},
- {"cd is builtin", "cd", true},
- {"test is builtin", "test", true},
- {"[ is builtin", "[", true},
- {"ls is not builtin", "ls", false},
- {"curl is not builtin", "curl", false},
- {"python3 is not builtin", "python3", false},
- {"nonexistent is not builtin", "nonexistent", false},
- }
-
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- result := isBuiltin(tt.command)
- if result != tt.expected {
- t.Errorf("IsBuiltin(%q) = %v, want %v", tt.command, result, tt.expected)
- }
- })
- }
-}
-
func TestExtractCommandsErrorHandling(t *testing.T) {
// Test with syntactically invalid bash
invalidBash := "if [ incomplete"
diff --git a/go.mod b/go.mod
index 95c16f2..8f7cc4b 100644
--- a/go.mod
+++ b/go.mod
@@ -21,9 +21,9 @@
golang.org/x/crypto v0.37.0
golang.org/x/net v0.39.0
golang.org/x/sync v0.13.0
- golang.org/x/term v0.31.0
+ golang.org/x/term v0.32.0
golang.org/x/tools v0.32.0
- mvdan.cc/sh/v3 v3.11.0
+ mvdan.cc/sh/v3 v3.11.1-0.20250530001257-46bb4f2b309f
)
require (
@@ -37,7 +37,7 @@
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
golang.org/x/mod v0.24.0 // indirect
- golang.org/x/sys v0.32.0 // indirect
+ golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.24.0 // indirect
)
diff --git a/go.sum b/go.sum
index 65d5385..431391b 100644
--- a/go.sum
+++ b/go.sum
@@ -123,6 +123,8 @@
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
+golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
+golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -134,6 +136,8 @@
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
+golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
+golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
@@ -160,3 +164,5 @@
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mvdan.cc/sh/v3 v3.11.0 h1:q5h+XMDRfUGUedCqFFsjoFjrhwf2Mvtt1rkMvVz0blw=
mvdan.cc/sh/v3 v3.11.0/go.mod h1:LRM+1NjoYCzuq/WZ6y44x14YNAI0NK7FLPeQSaFagGg=
+mvdan.cc/sh/v3 v3.11.1-0.20250530001257-46bb4f2b309f h1:T7SkxUwIOTm9iowqyQuUMY9oGEgZy5fE+TWNWgOj+yU=
+mvdan.cc/sh/v3 v3.11.1-0.20250530001257-46bb4f2b309f/go.mod h1:Se6Cj17eYSn+sNooLZiEUnNNmNxg0imoYlTu4CyaGyg=