mirror of
https://gitlab.com/pnx/gosh
synced 2026-06-16 07:04:57 +02:00
26 lines
584 B
Go
26 lines
584 B
Go
package runner
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
|
|
"gosh/internal/builtins"
|
|
"gosh/internal/command"
|
|
)
|
|
|
|
func cmd(def command.Definition) *exec.Cmd {
|
|
cmd := exec.Command(def.Name(), def.Arguments()...)
|
|
cmd.Stdin = os.Stdin
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Stdout = os.Stdout
|
|
return cmd
|
|
}
|
|
|
|
// Exec runs the provided command definition immediately. It is a thin wrapper
|
|
// around Resolve for convenience and backward compatibility.
|
|
func Exec(def command.Definition) error {
|
|
if builtin, found := builtins.Lookup(def.Name()); found {
|
|
return builtin(def.Arguments())
|
|
}
|
|
return cmd(def).Run()
|
|
}
|