1
0
Fork 0
mirror of https://gitlab.com/pnx/gosh synced 2026-06-16 07:04:57 +02:00
gosh/internal/runner/runner.go
2025-10-27 02:03:02 +01:00

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()
}