Skip to content

Commit

Permalink
add docs/comments to command prep code
Browse files Browse the repository at this point in the history
  • Loading branch information
eikenb committed Jul 18, 2022
1 parent 5944aff commit a23d3ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions child/command-prep.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"strings"
)

// Evaluates the command slice for the different possible formats.
// Returns the command slice ready to pass to exec.Command.
// Returns a boolean 'true' if it wrapped the call in 'sh -c' so the caller
// knows it needs to setpgid to get signal propagation.
func CommandPrep(command []string) ([]string, bool, error) {
switch {
case len(command) == 1 && len(strings.Fields(command[0])) > 1:
Expand Down
2 changes: 2 additions & 0 deletions child/command-prep_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"strings"
)

// Simplified command prep for windows. Only supports single or slice commands
// and doesn't wrap anything in a shell call (so bool is always false).
func CommandPrep(command []string) ([]string, bool, error) {
switch {
case len(command) == 1 && len(strings.Fields(command[0])) == 1:
Expand Down

0 comments on commit a23d3ac

Please sign in to comment.