Skip to content

Commit 62f63a2

Browse files
committed
Properly handle cross platform nul device
1 parent d7844b7 commit 62f63a2

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

nul

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Command/ServerCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,16 @@ private function launchInspector(ConsoleIo $io): int
228228
*/
229229
private function findExecutable(string $name): ?string
230230
{
231+
$nullDevice = DIRECTORY_SEPARATOR === '\\' ? 'nul' : '/dev/null';
232+
231233
// Try which command first (Unix/Linux/macOS)
232-
$which = trim((string)shell_exec(sprintf('which %s 2>/dev/null', escapeshellarg($name))));
234+
$which = trim((string)shell_exec(sprintf('which %s 2>%s', escapeshellarg($name), $nullDevice)));
233235
if ($which !== '' && is_executable($which)) {
234236
return $which;
235237
}
236238

237239
// Try where command (Windows)
238-
$where = trim((string)shell_exec(sprintf('where %s 2>nul', escapeshellarg($name))));
240+
$where = trim((string)shell_exec(sprintf('where %s 2>%s', escapeshellarg($name), $nullDevice)));
239241
if ($where !== '') {
240242
$paths = explode("\n", $where);
241243
$firstPath = trim($paths[0]);

0 commit comments

Comments
 (0)