diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 0be6c542..8ceea879 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -700,13 +700,17 @@ function ( $matches ) use ( $phar_path, $shell_path ) { * Replace variables callback. */ private function replace_var( $matches ) { - $cmd = $matches[0]; + $str = $matches[0]; foreach ( array_slice( $matches, 1 ) as $key ) { - $cmd = str_replace( '{' . $key . '}', $this->variables[ $key ], $cmd ); + $str = str_replace( + '{' . $key . '}', + array_key_exists( $key, $this->variables ) ? $this->variables[ $key ] : '', + $str + ); } - return $cmd; + return $str; } /**