hoaproject / Console

The Hoa\Console library.
https://hoa-project.net/
366 stars 32 forks source link

Escape command, options and line builder in Processus #42

Open Hywan opened 9 years ago

Hywan commented 9 years ago

Hello :-),

Hoa\Console\Processus automatically escape command and options. Moreover, when building the command line, it adds a = between the option name and the option value. See https://github.com/hoaproject/Console/blob/26092d3498fe34362511c5a7040b6daa50b3d175/Processus.php#L963-L1035.

In some case, this behavior is not desired. For instance, with atoum, when we build the command, we don't use the $options because = will be inserted and atoum does not support them. The solution is to pass the whole command line in $command, with the options. It's fine, this is how to deal with it. However, because Processus automatically escape the command, sometimes, it is not what we expect because escaping can create invalid command. Example: --filter 'class = "foo"' becomes --filter 'class = \"foo\"'.

2 solutions:

  1. we tell the users of this behavior in the documentation and we advice to extend Processus and override the setCommand method,
  2. we add one or more arguments in the constructor to disable the escaping.

Thoughts? /cc @hoaproject/hoackers

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9008277-escape-command-options-and-line-builder-in-processus?utm_campaign=plugin&utm_content=tracker%2F459935&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F459935&utm_medium=issues&utm_source=github).