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

**URL:** <https://discourse.julialang.org/t/how-to-pass-variable-in-macro-returned-run-var/100874>\
**Category:** General Usage\
**Created:** [June 27, 2023, 6:50am UTC](https://discourse.julialang.org/t/how-to-pass-variable-in-macro-returned-run-var/100874 "2023-06-27T06:50:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [June 27, 2023, 6:50am UTC](https://discourse.julialang.org/t/how-to-pass-variable-in-macro-returned-run-var/100874/1 "2023-06-27T06:50:32Z")

</div>

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

```julia
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 ? 

```

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [June 27, 2023, 6:59am UTC](https://discourse.julialang.org/t/how-to-pass-variable-in-macro-returned-run-var/100874/2 "2023-06-27T06:59:25Z")

</div>

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

```
