# Paste strings in \`Cmd\`

**URL:** <https://discourse.julialang.org/t/paste-strings-in-cmd/94050>\
**Category:** General Usage\
**Tags:** question, run\
**Created:** [February 4, 2023, 3:37pm UTC](https://discourse.julialang.org/t/paste-strings-in-cmd/94050 "2023-02-04T15:37:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rex\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rex_wang/32/35108_2.png) [@Rex\_Wang](https://discourse.julialang.org/u/Rex_Wang)\
**Post date:** [February 4, 2023, 3:37pm UTC](https://discourse.julialang.org/t/paste-strings-in-cmd/94050/1 "2023-02-04T15:37:06Z")

</div>

To avoid XY problem, I’ll describe the problem that needs to be solved first.

After building a JLL package, one can use

```julia
run(`$(product_name()) $args`)

```

to wrap an executable. (Then use `execute` to collect the results as describe [here](https://discourse.julialang.org/t/collecting-all-output-from-shell-commands/15592/2))

However, when passing `args` to the command,

```julia
args = "--opt file"
`cmd $args`

```

I get `cmd '--opt file'` rather than `cmd --opt file`, which could result in error.

So, **what is the right way to do it?**

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [February 4, 2023, 3:50pm UTC](https://discourse.julialang.org/t/paste-strings-in-cmd/94050/2 "2023-02-04T15:50:57Z")

</div>

Use `args = `--opt file` `. See for example

```julia
julia> args = "hello world"
"hello world"

julia> dump(`echo $args`)
Cmd
  exec: Array{String}((2,))
    1: String "echo"
    2: String "hello world"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""
  cpus: Nothing nothing

julia> args = `hello world`
`hello world`

julia> dump(`echo $args`)
Cmd
  exec: Array{String}((3,))
    1: String "echo"
    2: String "hello"
    3: String "world"
  ignorestatus: Bool false
  flags: UInt32 0x00000000
  env: Nothing nothing
  dir: String ""
  cpus: Nothing nothing

```

If `args` is a `String`, when interpolated it’s kept all together, like what you’d expect from strings, if instead it’s a `Cmd`, when interpolated it’s broken down in its components.
