godo icon indicating copy to clipboard operation
godo copied to clipboard

how should I use os/exec in a task?

Open jameshfisher opened this issue 9 years ago • 2 comments

I want to write a task which creates a subprocess by specifying a program name and some arguments. godo provides .Bash and .Run, neither of which are appropriate for me, because they seem to mush together arguments into a single string which will cause all kinds of edge-case bugs. I want an interface like that of Command in os/exec, where I can specify the arguments as a list of strings. What is the recommended way to achieve this?

jameshfisher avatar May 31 '16 12:05 jameshfisher

@The Bash and Run functions are sugar functions to aid in setting environment variables, template interpolation. strings.Join is an option if you have a slice of args.

ctx.Run("app " + strings.Join(args, " "))

mgutz avatar May 31 '16 15:05 mgutz

@mgutz unfortunately strings.Join isn't an option due to the obvious bugs it would introduce (think strings.Join(string[]{"foo bar", "baz"})). Is it possible for godo to expose a saner lower-level API where we can pass these arguments directly, and no intermediary shell process is invoked?

jameshfisher avatar May 31 '16 16:05 jameshfisher