From c412f1c1463327866baee117504c3a4b3fc33bd6 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Fri, 8 May 2020 15:49:31 +0200 Subject: Do not call it::_stdin_next() trying to open first optional argument unless it::gets() is used --- it.class | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/it.class b/it.class index a6e387b..b3505ea 100644 --- a/it.class +++ b/it.class @@ -932,7 +932,6 @@ static function getopt($usage, $p = array()) it_debug::set($result['debug']); $GLOBALS['it_stdin']['args'] = $result['args'] ? $result['args'] : array("-"); - it::_stdin_next(); if ($result['verbose']) $GLOBALS['debug_verbose']++; @@ -959,6 +958,11 @@ static function _stdin_next() */ static function gets() { + static $initialized = 0; + + if (!$initialized++) + it::_stdin_next(); + do { $result = fgets($GLOBALS['it_stdin']['fd']); } while (($result === false) && it::_stdin_next()); -- cgit v1.2.3