Skip to content

Commit 235e52a

Browse files
[8.x] Bugfix passing errorlevel when command is run in background (#37479)
* Call schedule:finish with errorlevel * Cmd with /v:on, escape expanded variable Co-authored-by: Arjen van Oostrum <[email protected]>
1 parent 56466a9 commit 235e52a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Illuminate/Console/Scheduling/CommandBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function buildBackgroundCommand(Event $event)
5252
$finished = Application::formatCommandString('schedule:finish').' "'.$event->mutexName().'"';
5353

5454
if (windows_os()) {
55-
return 'start /b cmd /c "('.$event->command.' & '.$finished.' "%errorlevel%")'.$redirect.$output.' 2>&1"';
55+
return 'start /b cmd /v:on /c "('.$event->command.' & '.$finished.' ^!ERRORLEVEL^!)'.$redirect.$output.' 2>&1"';
5656
}
5757

5858
return $this->ensureCorrectUser($event,

tests/Console/Scheduling/EventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testBuildCommandInBackgroundUsingWindows()
6161

6262
$scheduleId = '"framework'.DIRECTORY_SEPARATOR.'schedule-eeb46c93d45e928d62aaf684d727e213b7094822"';
6363

64-
$this->assertSame('start /b cmd /c "(php -i & "'.PHP_BINARY.'" artisan schedule:finish '.$scheduleId.' "%errorlevel%") > "NUL" 2>&1"', $event->buildCommand());
64+
$this->assertSame('start /b cmd /v:on /c "(php -i & "'.PHP_BINARY.'" artisan schedule:finish '.$scheduleId.' ^!ERRORLEVEL^!) > "NUL" 2>&1"', $event->buildCommand());
6565
}
6666

6767
public function testBuildCommandSendOutputTo()

0 commit comments

Comments
 (0)