Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21b2bf2

Browse files
javiereguiluznicolas-grekas
authored andcommitted
Minor rewords
1 parent5fd4c32 commit21b2bf2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

‎components/process.rst‎

Lines changed: 18 additions & 13 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 needto define commands as strings, variable arguments should be passed as
118-
environment variables using thesecond argumentofthe ``run()``, ``mustRun()`` or
119-
``start()`` methods. Referencing them in command-linestrings is OS-dependent::
115+
If you needuse stream redirections, conditional execution, or any other
116+
features provided by theshellofyour operating system, you can also define
117+
commands asstrings.
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
125130
$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)

[8]ページ先頭

©2009-2025 Movatter.jp