diff --git a/src/Helpers/CommandLine.php b/src/Helpers/CommandLine.php index f2cd6ac..f0789fd 100644 --- a/src/Helpers/CommandLine.php +++ b/src/Helpers/CommandLine.php @@ -29,7 +29,7 @@ public function __construct(string $command, ?string $workingDirectory, ?string if ($stdOut === self::STDOUT_TO_DEV_NULL) { $this->stdOut = ' > ' . $stdOut; } elseif ($stdOut !== null) { - $this->stdOut = ' 2> ' . ' > ' . escapeshellarg($stdOut); + $this->stdOut = ' > ' . escapeshellarg($stdOut); } } diff --git a/test/Helpers/CommandLineTest.php b/test/Helpers/CommandLineTest.php index f998517..935d945 100644 --- a/test/Helpers/CommandLineTest.php +++ b/test/Helpers/CommandLineTest.php @@ -67,6 +67,21 @@ public function testSimpleCommandWithWorkingDirAndStdErrAndStdOut(): void ); } + public function testSimpleCommandWithWorkingDirAndStdErrAndStdOutNonDefault(): void + { + $commandLine = new CommandLine( + 'ls', + '/opt', + '/var/log/err', + '/var/log/out' + ); + + self::assertSame( + "cd '/opt' && ls 2> '/var/log/err' > '/var/log/out'", + $commandLine->getFullCommand() + ); + } + public function testAdvancedCommandWithWorkingDirAndStdErrAndStdOut(): void { $commandLine = (new CommandLine(