Add MD_STD::exec_edit to run edit and pipe STDERR to a php exception
This commit is contained in:
parent
4c5097701f
commit
6db2b4cc1f
17
MD_STD.php
17
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
|
* Wrapper around levenshtein(), that only compares the first 250
|
||||||
* characters (levenshtein can't handle more than 255).
|
* characters (levenshtein can't handle more than 255).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user