diff --git a/MD_STD.php b/MD_STD.php index 327be44..abf98dd 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -431,6 +431,23 @@ final class MD_STD { } + /** + * Wrapper around exec, to be used with editing functions. + * Pipes STDERR to STDOUT and throws an Exception on any error. + * + * @param string $cmds Commands to run. + * + * @return void + */ + public static function exec_edit(string $cmds):void { + + $error = \exec($cmds . ' 2>&1'); + if (!empty($error)) { + throw new \Exception('Shell error: ' . $error); + } + + } + /** * Wrapper around levenshtein(), that only compares the first 250 * characters (levenshtein can't handle more than 255).