Implement system()
All checks were successful
Build / AerScript (push) Successful in 31s

This commit is contained in:
2025-08-28 15:14:59 +02:00
parent d4b6fd782e
commit be203e2e60
3 changed files with 38 additions and 0 deletions

View File

@@ -7257,6 +7257,35 @@ static int PH7_builtin_mktime(ph7_context *pCtx, int nArg, ph7_value **apArg) {
ph7_result_int64(pCtx, iVal);
return PH7_OK;
}
/*
* Section:
* System Functions
* Authors:
* Rafal Kupiec,belliash@codingworkshop.eu.org
* Status:
* Stable.
*/
/*
* bool system(string $command)
* Invokes an operating system command from AerScript.
* Parameters
* $command: String that contains the command to execute.
* Return
* TRUE if command executed successfully. False otherwise.
*/
int PH7_builtin_system(ph7_context *pCtx, int nArg, ph7_value **apArg) {
const char *zCmd = NULL;
int res = 0;
if(nArg > 0 && ph7_value_is_string(apArg[0])) {
zCmd = ph7_value_to_string(apArg[0], 0);
}
res = system(zCmd);
/* Query result */
ph7_result_bool(pCtx, res == 0);
return PH7_OK;
}
/*
* Section:
* URL handling Functions.
@@ -7455,6 +7484,7 @@ static const ph7_builtin_func aBuiltInFunc[] = {
{ "strripos", PH7_builtin_strripos },
{ "strrchr", PH7_builtin_strrchr },
{ "strrev", PH7_builtin_strrev },
{ "system", PH7_builtin_system },
{ "ucwords", PH7_builtin_ucwords },
{ "str_repeat", PH7_builtin_str_repeat },
{ "nl2br", PH7_builtin_nl2br },