From 7758be802e3011f6430ad17912fa2b4ab51ed7a3 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 10 May 2019 16:48:45 +0200 Subject: handle empty output in ->pipe() --- it_pipe.class | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'it_pipe.class') diff --git a/it_pipe.class b/it_pipe.class index 54f4a5b..cd1b54f 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -239,7 +239,8 @@ function pipe($cmd, ...$args) fwrite($pipes[0], join("\n", $this->lines) . ($this->lines ? "\n" :"")); fclose($pipes[0]); - $this->lines = explode("\n", rtrim(stream_get_contents($pipes[1]))); + $out = stream_get_contents($pipes[1]); + $this->lines = $out === "" ? [] : explode("\n", rtrim($out, "\n")); fclose($pipes[1]); proc_close($process); -- cgit v1.2.3