From cda15498f993c85e2c20351f0b248b05122e5705 Mon Sep 17 00:00:00 2001 From: Phil Burton Date: Wed, 9 Dec 2015 14:40:15 +0000 Subject: Add error colour --- search.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index ad511e4..cfc1a16 100644 --- a/search.php +++ b/search.php @@ -108,14 +108,22 @@ function getVersion($config) * * @param string|string[] $pieces * @param string $glue + * @param bool $sderr * @author Phil Burton */ -function output($pieces, $glue = " - ") +function output($pieces, $glue = " - ", $stderr = false) { + $out = ""; if (!is_array($pieces)) { - echo $pieces . "\n"; + $out = $pieces . "\n"; } else { - echo implode($glue, $pieces) . "\n"; + $out = implode($glue, $pieces) . "\n"; + } + + if ($stderr) { + echo "\x034" . $out . "\x03"; + } else { + echo $out; } exit; @@ -264,8 +272,8 @@ try { $out[] = "results (" . $count . ")"; } - output($out, " - "); + output($out); } catch (Exception $e) { - output($e->getMessage()); + output($e->getMessage(), " - ", true); } -- cgit v1.2.3