How to pass variable in macro returned run(`$var`)

Hello, how to pass variable in macro returned run($var)

macro foo(x)
    return esc(:(run(`$x`)))
end

@macroexpand @foo my_command  # -> :(run(Base.cmd_gen(((x,),))))
# i need
@macroexpand @foo my_command   # -> :(run(`my_command`))
# what i am doing wrong ? 

macro foo(x)
    cmd = `$x`
    return esc(:(run($cmd)))
end
1 Like