Ahc\Cli\Helper\Shell->getOutput() - No output stream (pipe)
shlomohass opened this issue · 2 comments
shlomohass commented
Hi,
I already fixed this issue and I just want to make sure I understand why you chose the NUL file descriptor....
OS : Windows 10
PHP: 8.2
Reproduce:
$shell = new Shell('echo hello');
$shell->execute();
echo $shell->getOutput();
/*
Warning: Undefined array key 1 in D:\server\bsik1\vendor\adhocore\cli\src\Helper\Shell.php on line 239
TypeError stream_get_contents(): Argument #1 ($stream) must be of type resource, null given
(thrown in D:\server\bsik1\vendor\adhocore\cli\src\Helper\Shell.php:239)
*/
I think its because the descriptor for windows is ['file', 'NUL', 'w']
.
If I set it to a normal write pipe everything is working as expected :
// Shell.php line 103:
protected function getDescriptors(): array
{
// $out = $this->isWindows() ? ['file', 'NUL', 'w'] : ['pipe', 'w'];
$out = $this->isWindows() ? ['pipe', 'w'] : ['pipe', 'w'];
return [
self::STDIN_DESCRIPTOR_KEY => ['pipe', 'r'],
self::STDOUT_DESCRIPTOR_KEY => $out,
self::STDERR_DESCRIPTOR_KEY => $out,
];
}
so I wonder why you decided to use this descriptor for windows?
Note that on windows running the php-cli tests have many failures...
I already fixed this issue (and tests) - Just reaching out to check before I submit my changes.
Great project BTW 😃
adhocore commented
hello thank you. will check later. haven't used windows in long time though