piotrmurach / tty-command

Execute shell commands with pretty output logging and capture stdout, stderr and exit status.
https://ttytoolkit.org
MIT License
400 stars 34 forks source link

Modified command ran when it contains special characters #38

Closed thisismydesign closed 6 years ago

thisismydesign commented 6 years ago

Hi,

I ran into the issue that I cannot execute the following command when passing the parameters one by one: git for-each-ref --format='%(refname)' refs/heads/

Because it tries to run this command instead: git for-each-ref '--format='%(refname)''%(refname)''' refs/heads/

See:

require 'tty-command'
cmd = TTY::Command.new
cmd.run(*['git', 'for-each-ref', "--format='%(refname)'", 'refs/heads/'])

A possible workaround is to do this: cmd.run("git for-each-ref --format='%(refname)' refs/heads/")

piotrmurach commented 6 years ago

Thanks for reporting this! I've removed self-baked solution for Ruby standard lib which correctly escapes arguments and makes multiple arguments work fine.

thisismydesign commented 6 years ago

Thanks for the quick fix :)