| 1 | package sandbox |
| 2 | |
| 3 | // unixShellCapabilities reports the common POSIX-family interpreters present |
| 4 | // on macOS and Linux. Linux remains Bash-only for execution; macOS may fall |
| 5 | // back to zsh and then sh when Bash is unavailable, while Settings reports the |
| 6 | // complete inventory on both platforms. |
| 7 | func unixShellCapabilities(snap *shellSnapshot) []ShellCapability { |
| 8 | return []ShellCapability{ |
| 9 | unixShellCapability(snap, ShellCapabilityBash, []string{"bash"}, []string{"/bin/bash", "/usr/bin/bash"}), |
| 10 | unixShellCapability(snap, ShellCapabilityZsh, []string{"zsh"}, []string{"/bin/zsh", "/usr/bin/zsh"}), |
| 11 | unixShellCapability(snap, ShellCapabilitySh, []string{"sh"}, []string{"/bin/sh", "/usr/bin/sh"}), |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | func unixShellCapability(snap *shellSnapshot, id string, names, standardPaths []string) ShellCapability { |
| 16 | capability := ShellCapability{ID: id, Variant: "system"} |
| 17 | for _, name := range names { |
| 18 | if path, err := snap.lookPath(name); err == nil { |
| 19 | capability.Available = true |
| 20 | capability.Path = path |
| 21 | capability.Source = ShellSourcePath |
| 22 | return capability |
| 23 | } |
| 24 | } |
| 25 | for _, path := range standardPaths { |
| 26 | if snap.exists(path) { |
| 27 | capability.Available = true |
| 28 | capability.Path = path |
| 29 | capability.Source = ShellSourceStandard |
| 30 | return capability |
| 31 | } |
| 32 | } |
| 33 | capability.Reason = "not-found" |
| 34 | return capability |
| 35 | } |
| 36 |