Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to run tmux, passing several commands at once, and I'm unable to properly quote the string.

The command succeeds when manually entered on the command line:

~% /usr/local/bin/tmux start-server\; set-option -g default-command '/usr/bin/true 1 2 3' \; new-session
[exited]

But in the real case, I need to build the command dynamically, and then I'm unable to get it to expand correctly. The single quotes seem to get discarded during the ${=var} expansion:

 ~% cmd="/usr/local/bin/tmux start-server; set-option -g default-command '/usr/bin/true 1 2 3' ; new-session"
 ~% ${=cmd}
usage: set-option [-agosquw] [-t target-session|target-window] option [value]

tmux doesn't understand the command when passed as a single string, i.e. not including the /usr/local/bin/tmux token in the string, and expanding the rest using ${cmd} as opposed to ${=cmd}.

~% /usr/local/bin/tmux 'start-server; set-option -g default-command "/usr/bin/true 1 2 3"; new-session'
unknown command: start-server; set-option -g default-command "/usr/bin/true 1 2 3"; new-session

my zsh version:

⚠~% ${SHELL} --version
zsh 5.0.2 (x86_64-apple-darwin12.2.1)
share|improve this question

1 Answer 1

${(z)var} expands the variable while keeping the inner quotes intact.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.