diff options
author | Phil Burton <phil@d3r.com> | 2015-12-09 14:40:15 +0000 |
---|---|---|
committer | Phil Burton <phil@d3r.com> | 2015-12-09 14:40:15 +0000 |
commit | cda15498f993c85e2c20351f0b248b05122e5705 (patch) | |
tree | 512d7513334017cc26b66eca6e106e680951f394 | |
parent | de76ff1e55ab2324d24b52f15b41df2fa372102c (diff) |
Add error colour
-rw-r--r-- | search.php | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -108,14 +108,22 @@ function getVersion($config) * * @param string|string[] $pieces * @param string $glue + * @param bool $sderr * @author Phil Burton <phil@pgburton.com> */ -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); } |