From f816a7d4dfd191c7920d2cf628b5c464b73adffa Mon Sep 17 00:00:00 2001 From: Alexandru TIRTAN Date: Mon, 10 Feb 2020 16:23:21 +0200 Subject: [PATCH] fixed bug --- src/Helpers/CommandLine.php | 2 +- test/Helpers/CommandLineTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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(