From 36ffd806aec597c6e3eff966d47f02cb23f66a7b Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 3 Jul 2023 21:35:29 +0200 Subject: mark it::exec call safe, give better it::exec example --- README | 2 +- it_pipe.class | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index d7fe5a9..c68934c 100644 --- a/README +++ b/README @@ -166,7 +166,7 @@ Functions: it::error($info) -- print or mail error message it::fatal($info) -- print or mail error message, then exit it::bail($message) -- print message to stderr, exit with errcode - it::exec($command, $values) -- execute command, return output + it::exec('command', $values) -- execute command, return output it::getopt($usage) -- parse (or print) usage, return options, it::gets() -- fetch next line from stdin or named arg it::imageconvert($params) -- Convert image using ImageMagick convert diff --git a/it_pipe.class b/it_pipe.class index ac1b987..73ce75a 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -19,7 +19,7 @@ function __construct($p = array()) if (array_key_exists('data', $p)) $this->lines = is_array($p['data']) || $p['data'] === null ? (array)$p['data'] : explode("\n", rtrim($p['data'], "\n")); else if (array_key_exists('cmd', $p)) - $this->lines = strlen($data = it::exec($p['cmd'], $p['args'])) ? explode("\n", rtrim($data, "\n")) : array(); + $this->lines = strlen($data = it::exec($p['cmd'], $p['args'])) ? explode("\n", rtrim($data, "\n")) : array(); # NOPHPLINT else foreach ((array)($p['fn'] ? $p['fn'] : "php://stdin") as $fn) $this->lines = array_merge((array)$this->lines, ($t = it::file($fn, FILE_IGNORE_NEW_LINES)) === false ? array() : $t); -- cgit v1.2.3