From 075c5e231bdca2acb1c7750e5a7f03261ac638b8 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Sat, 15 Apr 2023 18:51:15 +0200 Subject: [PATCH] MYVESTA_QUIET as export variable --- func/main.php | 2 ++ func/string.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/func/main.php b/func/main.php index 967fb8fb..22834d42 100644 --- a/func/main.php +++ b/func/main.php @@ -2,6 +2,8 @@ $myvesta_exit_on_error=true; $myvesta_quiet_mode=0; +if (isset($_SERVER['MYVESTA_QUIET'])) $myvesta_quiet_mode=intval($_SERVER['MYVESTA_QUIET']); + define('MYVESTA_ERROR_PERMISSION_DENIED', 1); define('MYVESTA_ERROR_MISSING_ARGUMENTS', 2); define('MYVESTA_ERROR_FILE_DOES_NOT_EXISTS', 3); diff --git a/func/string.php b/func/string.php index e4ba2a5f..371c643c 100644 --- a/func/string.php +++ b/func/string.php @@ -81,8 +81,8 @@ function myvesta_grep($find, $file_or_stdin, $count=0, $quiet=0) { $myvesta_quiet_mode=$quiet; //echo "find = " . $find."\n"; echo "file_or_stdin = " . $file_or_stdin."\n"; echo "count = " . $count."\n"; echo "quiet = " . $quiet."\n"; exit; if ($myvesta_stdin_return_not_found==true) { - if ($count==1) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "0"); - return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, ""); + if ($count==1) return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "0"); + return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, ""); } $arr=explode("\n", $file_or_stdin); @@ -111,7 +111,7 @@ function myvesta_sed($find, $replace, $file_or_stdin) { global $myvesta_stdin, $myvesta_stdin_return_not_found, $myvesta_stdin_from_file; //echo "find = " . $find."\n"; echo "replace = " . $replace."\n"; echo "file_or_stdin = " . $file_or_stdin."\n"; echo "stdin_from_file = " . $myvesta_stdin_from_file."\n"; exit; if ($myvesta_stdin_return_not_found==true) { - return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "File not found"); + return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "File not found"); } if (strpos($file_or_stdin, $find)===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "String '$find' not found");