Single quotes prevent interpolation
ngirard opened this issue · comments
let pwd = env::var("PWD").unwrap();
cmd!("echo 'Hello from {pwd}'").run()?;
produces
Hello from {pwd}
instead of the expected
Hello from /home/ngirard/....
I wouldn't say that this is an explicitly designed behavior, but I think it is reasonable. The shell works that way, there's no interpolation in single quotes.
let pwd = env::var("PWD").unwrap();
cmd!("echo 'Hello from '{pwd}").run()?;
will do what you want
Well, I'm not sure it's the most readable & comfortable option...
Let's take another example: notify-send
expects the string to be displayed to be given as a single argument.
What would then be the equivalent Xshell cmd!
statement to the following shell command ?
notify-send "Hello from $PWD"
cmd!(“notify-send 'Hello from '{PWD}“)
Adjacent tokens are concated into a single arg. But I do agree that this is kinda silly. I think I need to bite the bullet and implement proper escapensequences and double quoted strings, so that your example just works.
I think that would be a valuable improvement.
Thanks in advance !
The shell works that way, there's no interpolation in single quotes
So it is okay to close this issue.