Skip to content

Commit 7cff554

Browse files
javiereguiluznicolas-grekas
authored andcommitted
Minor rewords
1 parent 5fd4c32 commit 7cff554

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

components/process.rst

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,34 @@ with a non-zero code)::
103103
.. tip::
104104

105105
.. versionadded:: 3.3
106-
The ability to define commands as array of arguments was introduced in Symfony 3.3.
106+
The ability to define commands as arrays of arguments was introduced in
107+
Symfony 3.3.
107108

108-
When defining commands as arrays, its arguments are escaped for you and you should not
109-
escape them any further. You can also define commands as strings. When doing so, the
110-
command-line is parsed by the underlying shell of your operating system. This allows
111-
using e.g. stream redirections or conditional execution, but this is a lot less portable
112-
since each OS (esp. Windows vs Unix-like) handles escaping and parsing differently.
113-
When passing a command-line string, it becomes your responsibility to deal with this.
109+
Using array of arguments is the recommended way to define commands. This
110+
saves you from any escaping and allows sending signals seamlessly
111+
(e.g. to stop processes before completion.)::
114112

115-
Using array of arguments is the recommended way to define commands.
113+
$process = new Process(array('/path/command', '--flag', 'arg 1', 'etc.'));
116114

117-
If you need to define commands as strings, variable arguments should be passed as
118-
environment variables using the second argument of the ``run()``, ``mustRun()`` or
119-
``start()`` methods. Referencing them in command-line strings is OS-dependent::
115+
If you need use stream redirections, conditional execution, or any other
116+
features provided by the shell of your operating system, you can also define
117+
commands as strings.
120118

121-
// On Unix-like OSes
119+
Please note that each OS provides a different syntax for their command-lines
120+
so that it becomes your responsibility to deal with escaping and portability.
121+
122+
To provide any variable arguments to command-line string, pass them as
123+
environment variables using the second argument of the ``run()``,
124+
``mustRun()`` or ``start()`` methods. Referencing them is also OS-dependent::
125+
126+
// On Unix-like OSes (Linux, macOS)
122127
$process = new Process('echo "$MESSAGE"');
123128

124129
// On Windows
125-
$process = new Process('echo %MESSAGE%');
130+
$process = new Process('echo !MESSAGE!');
126131

127132
// On both Unix-like and Windows
128-
$process->run(null, 'MESSAGE' => 'Something to output']);
133+
$process->run(null, array('MESSAGE' => 'Something to output'));
129134

130135
Getting real-time Process Output
131136
--------------------------------

0 commit comments

Comments
 (0)