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

Escaping command #6

Closed piotrmurach closed 8 years ago

piotrmurach commented 8 years ago

Escaping can be a challenge with the current syntax. What should this do? cmd.execute(:ls, "hello world")

[71555-047a57b2] Running ls hello world
[71555-047a57b2]    ls: hello: No such file or directory
[71555-047a57b2]    ls: world: No such file or directory
[71555-047a57b2] Finished in 0.002 seconds with exit status 1 (failed)
piotrmurach commented 8 years ago

Sure you can execute the command the way you have mentioned. The readme is definitely not comprehensive yet. If you run cmd.execute("ls -la > output") it will respect the redirect and execute the string as is. There are many ways to pass the arguments which try to mimic the spawn behaviour.

gurgeous commented 8 years ago

This is probably worth some further discussion. We might want to mimic the current Ruby behavior:

>> system("ls", "hello world")
ls: hello world: No such file or directory
piotrmurach commented 8 years ago

Agree mimicking Ruby behaviour.

piotrmurach commented 8 years ago

Do you have time to work on this?