@@ -11,6 +11,7 @@ import (
1111 "github.com/dagu-org/dagu/internal/core"
1212 "github.com/dagu-org/dagu/internal/core/spec"
1313 "github.com/goccy/go-yaml"
14+ "github.com/kballard/go-shellquote"
1415)
1516
1617// ExecOptions captures the inline configuration for building an ad-hoc DAG.
@@ -36,9 +37,9 @@ type execSpec struct {
3637}
3738
3839type execStep struct {
39- Name string `yaml:"name"`
40- Command [] string `yaml:"command,omitempty"`
41- Shell string `yaml:"shell,omitempty"`
40+ Name string `yaml:"name"`
41+ Command string `yaml:"command,omitempty"`
42+ Shell string `yaml:"shell,omitempty"`
4243}
4344
4445func buildExecDAG (ctx * Context , opts ExecOptions ) (* core.DAG , string , error ) {
@@ -54,6 +55,10 @@ func buildExecDAG(ctx *Context, opts ExecOptions) (*core.DAG, string, error) {
5455 return nil , "" , fmt .Errorf ("invalid DAG name: %w" , err )
5556 }
5657
58+ // Join command args into a single properly quoted string
59+ // This ensures the command is treated as a single command, not multiple commands
60+ commandStr := shellquote .Join (opts .CommandArgs ... )
61+
5762 specDoc := execSpec {
5863 Name : name ,
5964 Type : core .TypeChain ,
@@ -64,7 +69,7 @@ func buildExecDAG(ctx *Context, opts ExecOptions) (*core.DAG, string, error) {
6469 Steps : []execStep {
6570 {
6671 Name : defaultStepName ,
67- Command : opts . CommandArgs ,
72+ Command : commandStr ,
6873 Shell : opts .ShellOverride ,
6974 },
7075 },
0 commit comments