summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2020-09-15 13:37:29 +0200
committerChristian Schneider2020-09-15 13:37:29 +0200
commit5359b07a5c61588c680894c9c5ddc7aa47deb275 (patch)
tree5264e0c06d2c30560fdddeb544710974f5fd22c1
parent79fd50e172a50918d9018f54ab6e40606181f95b (diff)
downloaditools-5359b07a5c61588c680894c9c5ddc7aa47deb275.tar.gz
itools-5359b07a5c61588c680894c9c5ddc7aa47deb275.tar.bz2
itools-5359b07a5c61588c680894c9c5ddc7aa47deb275.zip
Do not generate warning (PHP 8: TypeError) if STDERR is not a valid resource, e.g. in test/getopt.t because of backgrounding?!
-rw-r--r--it.class3
1 files changed, 2 insertions, 1 deletions
diff --git a/it.class b/it.class
index 0d3cdec..45cc2cb 100644
--- a/it.class
+++ b/it.class
@@ -929,7 +929,8 @@ static function getopt($usage, $p = array())
it::error("Optional arguments passed to script without optional args in usage"); # FIXME 2020-10 NG merge with normal usage errors below
if ($err || $eat || $result['h'] || $result['help'] || $mandatoryargs)
{
- fputs(($result['h'] || $result['help'] ? STDOUT : STDERR), trim($usage) . "\n");
+ if (is_resource($out = $result['h'] || $result['help'] ? STDOUT : STDERR))
+ fputs($out, trim($usage) . "\n");
return $p['noexit'] ? false : exit(1);
}