rename args argv

This commit is contained in:
Jeff Carr 2024-11-13 11:56:25 -06:00
parent d986f8f331
commit bc31c85413
1 changed files with 9 additions and 9 deletions

18
cmd.go
View File

@ -48,26 +48,26 @@ func PathRun(path string, argv []string) cmd.Status {
// the actual wrapper around go-cmd/cmd
// adds a log Flag so that echo to stdout can be enabled/disabled
func PathRunLog(path string, args []string, logf *log.LogFlag) cmd.Status {
func PathRunLog(path string, argv []string, logf *log.LogFlag) cmd.Status {
var save []string // combined stdout & stderr
var arg0 string
var argx []string
var args []string
if logf == nil {
logf = NOW
}
log.Log(logf, "shell.PathRunLog():", args)
log.Log(logf, "shell.PathRunLog() Path =", path, "cmd =", argv)
// Check if the slice has at least one element (the command name)
if len(args) == 0 {
if len(argv) == 0 {
var s cmd.Status
s.Error = errors.New("Error: Command slice is empty.")
return s
}
if len(args) == 1 {
if len(argv) == 1 {
// Pass the first element as the command, and the rest as variadic arguments
arg0 = args[0]
arg0 = argv[0]
} else {
arg0 = args[0]
argx = args[1:]
arg0 = argv[0]
args = argv[1:]
}
// Disable output buffering, enable streaming
@ -77,7 +77,7 @@ func PathRunLog(path string, args []string, logf *log.LogFlag) cmd.Status {
}
// Create Cmd with options
envCmd := cmd.NewCmdOptions(cmdOptions, arg0, argx...)
envCmd := cmd.NewCmdOptions(cmdOptions, arg0, args...)
if path != "" {
// set the path for exec
envCmd.Dir = path