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

Appearance settings

[Process] Allow writing portable "prepared" command lines #23778

Copy link
Copy link
Closed
@nicolas-grekas

Description

@nicolas-grekas
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3.4

With 3.3, we already support "prepared" command lines.

$process = new Process('echo $abc && echo $def');
$process->inheritEnvironmentVariables(); // unrelated, just for FC

$process->run(null, array('abc' => 'ABC', 'def' => 'DEF'); // echoes ABCDEF

It works quite simply: it just creates the corresponding env vars and leverages the underlying shell to parse the command line and use the values. The $abc syntax comes from sh of course, nothing we have to deal with fortunately.

BUT this comes with a drawback, namely: portability. Why? Because we rely on the shell to parse the command line :)
On Windows, the same command has to be written as echo !abc! && echo !def!, using the !foo! syntax from Windows' shell (cmd.com) to use env vars.

While creating a portable command line language is out of scope, we could at least provide some portable syntax for env vars injection.

One proposal as already been made, using curly brackets: echo {abc} && echo {def}.
WDYT?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.