-
Notifications
You must be signed in to change notification settings - Fork 782
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace shell parsing w/ direct shell call
Instead of trying to parse the shell command line into arguments for input to exec.Command this replaces that all with passing it to an 'sh -c' call. This will "fix" the wack-o-mole game of spot fixing issues that keep coming up with the shell parsing package. Windows is handled separately (no 'sh') and is setup to only accept/run a single command.
- Loading branch information
Showing
4 changed files
with
154 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package manager | ||
|
||
const whitespace = " \t\n\v\f\r" | ||
|
||
func prepCommand(command string) ([]string, error) { | ||
if len(command) == 0 { | ||
return []string{}, nil | ||
} | ||
|
||
cmd := []string{"sh", "-c", command} | ||
return cmd, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// +build windows | ||
|
||
package manager | ||
|
||
func prepCommand(command string) ([]string, error) { | ||
switch { | ||
case len(command) == 0: | ||
return []string{}, nil | ||
case len(strings.Fields(command)) > 1: | ||
return cmd, fmt.Errorf("only single commands supported on windows") | ||
} | ||
return []string{command}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters