The Crystal Programming Language Forum

Question about Process.run

Hello, I have a question about a special case.
I need to run configure command for a source (gcc), but I need to prefix this with mlist=m64,m32,mx32. Is it possible to do that with Process.run ?

For example if I will do this, it will work ?

Process.run("mlist=m64,m32,mx32", args: ["./configure", ....options ...etc])

Pass the variables defined before calling the command as env vars.

Process.run("./configure", args: [options...],
            env: {"mlist" => "m64,m32,mx32"})
1 Like

Is it mandatory to use env like this, or can I just put a string as argument, like :

Process.run("./configure", args: [options...],
            env: ["mlist=m64,m32,mx32"])

env is of type Env which is defined here as:

alias Env = Nil | Hash(String, Nil) | Hash(String, String?) | Hash(String, String)

So no, you cannot pass an array of Strings.

Oh okay … Thanks you

Found that you can pass shell: true and pass all the things as single string.

Process.run("mlist=m64,m32,mx32 ./configure ....options ...etc", shell: true)
2 Likes

Oh nice, thanks you !