Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] BC Break exported bash functions as environment variables #21704

Closed
@hboomsma

Description

@hboomsma
Q A
Bug report? yes
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.2.x

This problem occurs after an upgrade to symfony 3.2.x if you use kriswallsmith/assetic and have exported bash functions in your current environment variables. In previous versions they were ignored by proc_open but in the 3.2 branch they are added using a self built environment string which tries to load these functions into sh which respectfully declines. This causes a bc break.

Results per symfony/process version when adding a bash function environment variable:

Installed 3.1.*
========================================
hello world

Installed 3.2.0
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed *
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed 3.2.x-dev
========================================
sh: 1: export: BASH_FUNC_foo%%: bad variable name

Installed dev-master
========================================
hello world

The script to check:

#!/usr/bin/env bash                                                                                                                                                                                                  
# Create and export bash function                                                                                                                                                                                    
foo() { echo 'bar'; }                                                                                                                                                                                                
export -f foo                                                                                                                                                                                                        
                                                                                                                                                                                                                     
# Load bash function foo and add it to a process                                                                                                                                                                     
# using a process builder, run it and show output.                                                                                                                                                                   
PHPCODE='                                                                                                                                                                                                            
require __DIR__ . "/vendor/autoload.php";                                                                                                                                                                            
                                                                                                                                                                                                                     
$foo = getenv("BASH_FUNC_foo%%");                                                                                                                                                                                    
$pb = new \Symfony\Component\Process\ProcessBuilder(["echo", "hello world"]);                                                                                                                                        
$pb->setEnv("BASH_FUNC_foo%%", $foo);                                                                                                                                                                                
$p = $pb->getProcess();                                                                                                                                                                                              
$p->run();                                                                                                                                                                                                           
                                                                                                                                                                                                                     
echo $p->getErrorOutput() . $p->getOutput() . PHP_EOL;                                                                                                                                                               
'                                                                                                                                                                                                                    
                                                                                                                                                                                                                     
# Try multiple versions of the symfony/process component                                                                                                                                                             
for VERSION in '3.1.*' '3.2.0' '*' '3.2.x-dev' 'dev-master'; do                                                                                                                                                      
    composer -q require symfony/process "$VERSION"                                                                                                                                                                   
    echo "Installed $VERSION"                                                                                                                                                                                        
    echo '=================='                                                                                                                                                                                        
    php -r "$PHPCODE"                                                                                                                                                                                                
done  

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