1
0
Fork 0

Initial commit

This commit is contained in:
Henrik Hautakoski 2025-10-26 23:49:09 +01:00
commit 9d9d8ce7d5
19 changed files with 399 additions and 0 deletions

3
internal/runner/doc.go Normal file
View file

@ -0,0 +1,3 @@
// Package runner executes command definitions by dispatching builtins
// or starting external programs in new processes.
package runner

26
internal/runner/runner.go Normal file
View file

@ -0,0 +1,26 @@
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()
}