system-cmd-fork added
This commit is contained in:
17
ml.cpp
17
ml.cpp
@@ -1331,6 +1331,22 @@ MlValue system_cmd(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
return exec_system_cmd(args[0].as_string());
|
||||
}
|
||||
|
||||
// Execute system command as forked process so its independent from its parrent
|
||||
MlValue system_cmd_fork(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
eval_args(args, env);
|
||||
|
||||
// TODO add support for more params constructing options as one string
|
||||
if (args.size() < 1)
|
||||
throw MlError(MlValue("system-cmd-fork", system_cmd_fork), env, TOO_FEW_ARGS);
|
||||
|
||||
std::vector<std::string> exec_args;
|
||||
exec_args.reserve(args.size());
|
||||
for (auto const& a : args)
|
||||
exec_args.emplace_back(a.as_string());
|
||||
|
||||
return exec_system_cmd_fork(exec_args);
|
||||
}
|
||||
|
||||
|
||||
// list directory
|
||||
MlValue ls_dir(std::vector<MlValue> args, MlEnvironment &env) {
|
||||
@@ -2241,6 +2257,7 @@ std::map<const std::string, Builtin> builtin_funcs
|
||||
std::make_pair("write-file", builtin::write_file),
|
||||
std::make_pair("read-url", builtin::read_url),
|
||||
std::make_pair("system-cmd", builtin::system_cmd),
|
||||
std::make_pair("system-cmd-fork", builtin::system_cmd_fork),
|
||||
std::make_pair("ls-dir", builtin::ls_dir),
|
||||
std::make_pair("is-file?", builtin::is_file),
|
||||
std::make_pair("is-dir?", builtin::is_dir),
|
||||
|
||||
Reference in New Issue
Block a user