| 1 | package proc |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "os/exec" |
| 6 | ) |
| 7 | |
| 8 | // Command constructs a desktop background command. On Windows it is hidden by |
| 9 | // default so new Git/probe/index/update checks cannot accidentally flash a |
| 10 | // console window. |
| 11 | func Command(name string, args ...string) *exec.Cmd { |
| 12 | cmd := exec.Command(name, args...) |
| 13 | HideWindow(cmd) |
| 14 | return cmd |
| 15 | } |
| 16 | |
| 17 | // CommandContext is Command with cancellation. |
| 18 | func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd { |
| 19 | // Dynamic executables are intentional for approved tools and terminals; name |
| 20 | // and args remain separate argv values, with any shell explicit at the caller. |
| 21 | // codeql[go/command-injection] |
| 22 | cmd := exec.CommandContext(ctx, name, args...) |
| 23 | HideWindow(cmd) |
| 24 | return cmd |
| 25 | } |
| 26 | |
| 27 | // VisibleCommand is the explicit escape hatch for a user-requested GUI, |
| 28 | // terminal, installer or application relaunch. |
| 29 | func VisibleCommand(name string, args ...string) *exec.Cmd { |
| 30 | return exec.Command(name, args...) |
| 31 | } |
| 32 | |
| 33 | // VisibleCommandContext is the context-aware visible escape hatch. |
| 34 | func VisibleCommandContext(ctx context.Context, name string, args ...string) *exec.Cmd { |
| 35 | return exec.CommandContext(ctx, name, args...) |
| 36 | } |
| 37 |