Skip to content

Commit

Permalink
Include stderr in $output by default
Browse files Browse the repository at this point in the history
Redirect stderr to stdout to have it included in output by default.
  • Loading branch information
danmichaelo committed Aug 13, 2016
1 parent a756380 commit cee2d60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ private function __construct()
*
* @throws \Exception
*/
public static function exec($command, array $params = array())
public static function exec($command, array $params = array(), $mergeStdErr=true)
{
if (empty($command)) {
throw new \InvalidArgumentException('Command line is empty');
}

$command = self::bindParams($command, $params);

if ($mergeStdErr) {
// Redirect stderr to stdout to include it in $output
$command .= ' 2>&1';
}

exec($command, $output, $code);

if (count($output) === 0) {
Expand Down

0 comments on commit cee2d60

Please sign in to comment.