34 lines
725 B
Go
34 lines
725 B
Go
package exec_extra
|
|
|
|
import (
|
|
`r00t2.io/sysutils/paths`
|
|
)
|
|
|
|
/*
|
|
CmdArgsWithBin returns a cmdArgsOpt that specifies program/executable/binary path `bin`,
|
|
ensuring that the resulting cmdSlice from GetCmdFromStruct() will return a ready-to-use slice.
|
|
(Otherwise the executable would need to be prepended to the resulting slice.)
|
|
|
|
Path normalization/canonziation can be enabled/disabled via normalizePath.
|
|
*/
|
|
func CmdArgsWithBin(bin string, normalizePath bool) (opt cmdArgOpt, err error) {
|
|
|
|
if normalizePath {
|
|
if err = paths.RealPath(&bin); err != nil {
|
|
return
|
|
}
|
|
}
|
|
|
|
opt = func(opts *cmdArgsOpts) (err error) {
|
|
/*
|
|
if opts.cmd == nil {
|
|
opts.cmd = new(string)
|
|
}
|
|
*/
|
|
*opts.cmd = bin
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|