-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Description
When running a lot of small shell commands after each other, the overhead of creating the underlying processes becomes noticeable. It would be handy if the process component would support chaining commands.
Working directly on a Linux/Windows shell you would typically do this:
# Linux
$ foo; bar; baz
$ foo && bar && baz
# Windows
$ foo & bar & baz
$ foo && bar && baz
(Yes there are other chaining operators as well like ||
.)
This is currently not possible with the process component.
API Example
I like that Symfony\Component\Process\Process
became somewhat immutable now (the command line is baked in after the constructor ran), so the API could maybe look like this:
$process = new Process(['foo']);
// foo; bar
$process = $process->withChainedCommand(['bar']); // returns a new process instance
// foo && bar
$process = $process->withAndChainedCommand(['bar']); // returns a new process instance
What do you think? Is this a worthwhile addition?
JoshMoreno, bigfoot90, icanhazstring, mtamazlicaru-crunchyroll, ging-dev and 4 moreausi, bchatard, alexandre-daubois, JoshMoreno, ging-dev and 3 more