8000 [Process] document command-as-arrays by nicolas-grekas · Pull Request #9988 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Process] document command-as-arrays #9988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2018
Merged

Conversation

nicolas-grekas
Copy link
Member

Fixed #9897

command-line is parsed by the underlying shell of your operating system. This allows
using e.g. stream redirections or conditional execution, but this is a lot less portable
since each OS (esp. Windows vs Unix-like) deals with escaping and parsing differently.
When passing a command-line string, it becomes your responsibility to deal this.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deal with this

@nicolas-grekas nicolas-grekas force-pushed the process-up branch 2 times, most recently from 80aa41d to f9a9eaa Compare July 1, 2018 16:11
$process = new Process('echo %MESSAGE%');

// On both Unix-like and Windows
$process->run(null, 'MESSAGE' => 'Something to output']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command is missing or what did I miss?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command is echo ... This line is the ->run() method call, which is the same for all OS. Only the command definition depends on the OS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, when I read this part it feels like it wants to show me the difference between using a string or an array value which is not the case. That's a bit confusing.
Not sure you understand what I mean. So when I read On both Unix-like and Windows it sounds to me like the example should tell me how I could make the command run on both systems without dealing with escaping. Oh man, this is hard to explain 😄

Symfony 3.3.

Defining commands as arrays of arguments is recommended because the Process
component escapes those arguments automatically. Defining commands as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Automatically escaping" does not seem to be the right wording according to your comment in symfony/symfony#27796 (comment) 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworded :)

@nicolas-grekas nicolas-grekas force-pushed the process-up branch 3 times, most recently from 21b2bf2 to 7cff554 Compare July 3, 2018 11:25
@xabbuh
Copy link
Member
xabbuh commented Aug 4, 2018

Thank you @nicolas-grekas.

@xabbuh xabbuh merged commit b638c88 into symfony:3.4 Aug 4, 2018
xabbuh added a commit that referenced this pull request Aug 4, 2018
This PR was merged into the 3.4 branch.

Discussion
----------

[Process] document command-as-arrays

Fixed #9897

Commits
-------

b638c88 [Process] document command-as-arrays

$process = new Process(array('/path/command', '--flag', 'arg 1', 'etc.'));

If you need use stream redirections, conditional execution, or any other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to use

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed in 2c5579b

xabbuh added a commit that referenced this pull request Aug 7, 2018
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Aug 8, 2018
* 3.4:
  Simplified the "Release Process" page
  [Workflow] Fix typo documentation
  Fix mismatched list items
  [symfony#9988] fix minor typos
  [symfony#10099] update XML and PHP config examples
  [symfony#9969] fix a minor typo
  [symfony#10022] fix a minor typo
  preUpdate Event Listener On Uploaded Imagery
  [symfony#10124] fix XML attribute name
  [symfony#10062] fix the code block
  [PHPUnitBridge] Explain how to show stack traces
  Fix docs on trusted hosts
  opcode optimizations
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Aug 8, 2018
* 4.1:
  Simplified the "Release Process" page
  [Workflow] Fix typo documentation
  Fix mismatched list items
  typos in sample code
  [symfony#9988] fix minor typos
  [symfony#10099] update XML and PHP config examples
  [symfony#9969] fix a minor typo
  [symfony#10022] fix a minor typo
  preUpdate Event Listener On Uploaded Imagery
  [symfony#9757] fix rst syntax
  [symfony#10124] fix XML attribute name
  [symfony#10062] fix the code block
  [PHPUnitBridge] Explain how to show stack traces
  Fix docs on trusted hosts
  opcode optimizations
@nicolas-grekas nicolas-grekas deleted the process-up branch November 10, 2018 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0