aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-06-20 01:44:16 +0900
committerOphestra <cat@gensokyo.uk>2026-06-20 01:44:47 +0900
commita7485d587ab0f4692fb16202172f6443cff7a49e (patch)
tree92e99ea91346f7b051e59ea357a7d6b6d3000670 /cmd
parent4892beefc18d409dcb99b27e0980df4537cad692 (diff)
cmd/app: pass user-specified arguments
An extra argument is added to pad out argv0. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/app/app.go2
-rw-r--r--cmd/app/app_test.go1
-rw-r--r--cmd/app/main.go4
-rw-r--r--cmd/app/run.go8
4 files changed, 11 insertions, 4 deletions
diff --git a/cmd/app/app.go b/cmd/app/app.go
index 205a0342..7e67763f 100644
--- a/cmd/app/app.go
+++ b/cmd/app/app.go
@@ -112,7 +112,7 @@ func parse(id string, base *check.Absolute, r io.Reader) (*hst.Config, error) {
if err := scanOnce(); err != nil {
return nil, err
}
- c.Container.Args = append(c.Container.Args, s.Text())
+ c.Container.Args = append(c.Container.Args, s.Text(), "")
var flagGPU, flagSystemBus bool
flags := map[string]*bool{
diff --git a/cmd/app/app_test.go b/cmd/app/app_test.go
index 76bce4c3..8f724c8d 100644
--- a/cmd/app/app_test.go
+++ b/cmd/app/app_test.go
@@ -120,6 +120,7 @@ talk com.canonical.Unity
Args: []string{
"zsh", "-ic",
"exec Discord --ozone-platform-hint=wayland",
+ "",
},
Flags: hst.FCoverRun | hst.FUserns | hst.FHostNet | hst.FMapRealUID |
diff --git a/cmd/app/main.go b/cmd/app/main.go
index d937ceac..b911e7dd 100644
--- a/cmd/app/main.go
+++ b/cmd/app/main.go
@@ -148,7 +148,7 @@ func main() {
c.NewCommand(
"run", "Start the named application",
func(args []string) error {
- if len(args) != 1 {
+ if len(args) < 1 {
dents, err := os.ReadDir(base.Append("app").String())
if err != nil {
return err
@@ -197,7 +197,7 @@ func main() {
config.Container.Args[2] = flagCommand
}
- return run(ctx, msg, config)
+ return run(ctx, msg, config, args[1:]...)
},
).
Flag(
diff --git a/cmd/app/run.go b/cmd/app/run.go
index 16f8b885..b8512579 100644
--- a/cmd/app/run.go
+++ b/cmd/app/run.go
@@ -12,7 +12,12 @@ import (
)
// run starts a container via cmd/hakurei and returns after it terminates.
-func run(ctx context.Context, msg message.Msg, config *hst.Config) error {
+func run(
+ ctx context.Context,
+ msg message.Msg,
+ config *hst.Config,
+ args ...string,
+) error {
c, cancel := context.WithCancel(ctx)
defer cancel()
@@ -25,6 +30,7 @@ func run(ctx context.Context, msg message.Msg, config *hst.Config) error {
cmd.Args = append(cmd.Args, "-v")
}
cmd.Args = append(cmd.Args, "run", "3")
+ cmd.Args = append(cmd.Args, args...)
r, w, err := os.Pipe()
if err != nil {