This commit is contained in:
parent
d4b6fd782e
commit
be203e2e60
@ -7257,6 +7257,35 @@ static int PH7_builtin_mktime(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
|||||||
ph7_result_int64(pCtx, iVal);
|
ph7_result_int64(pCtx, iVal);
|
||||||
return PH7_OK;
|
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:
|
* Section:
|
||||||
* URL handling Functions.
|
* URL handling Functions.
|
||||||
@ -7455,6 +7484,7 @@ static const ph7_builtin_func aBuiltInFunc[] = {
|
|||||||
{ "strripos", PH7_builtin_strripos },
|
{ "strripos", PH7_builtin_strripos },
|
||||||
{ "strrchr", PH7_builtin_strrchr },
|
{ "strrchr", PH7_builtin_strrchr },
|
||||||
{ "strrev", PH7_builtin_strrev },
|
{ "strrev", PH7_builtin_strrev },
|
||||||
|
{ "system", PH7_builtin_system },
|
||||||
{ "ucwords", PH7_builtin_ucwords },
|
{ "ucwords", PH7_builtin_ucwords },
|
||||||
{ "str_repeat", PH7_builtin_str_repeat },
|
{ "str_repeat", PH7_builtin_str_repeat },
|
||||||
{ "nl2br", PH7_builtin_nl2br },
|
{ "nl2br", PH7_builtin_nl2br },
|
||||||
|
6
tests/execute_system.aer
Normal file
6
tests/execute_system.aer
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Program {
|
||||||
|
public void main() {
|
||||||
|
bool $res = system("echo OK");
|
||||||
|
print("Result: ", $res);
|
||||||
|
}
|
||||||
|
}
|
2
tests/execute_system.exp
Normal file
2
tests/execute_system.exp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
OK
|
||||||
|
Result: TRUE
|
Loading…
x
Reference in New Issue
Block a user