Skip to content

Commit 55abfaf

Browse files
committed
Implement OS.system
1 parent 0ebcb10 commit 55abfaf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

vm/boostenv/lib/OS.oz

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export
7575

7676
GetHostByName
7777
UName
78+
System
7879

7980
% Process management
8081
SpawnProcess
@@ -196,6 +197,7 @@ define
196197

197198
GetHostByName = Boot_OS.getHostByName
198199
UName = Boot_OS.uName
200+
System = Boot_OS.system
199201

200202
%% Process management
201203

vm/boostenv/main/modos.hh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,19 @@ public:
457457
}
458458
};
459459

460+
class System: public Builtin<System> {
461+
public:
462+
System(): Builtin("system") {}
463+
464+
static void call(VM vm, In cmd, Out status) {
465+
size_t cmdBufSize = ozVSLengthForBuffer(vm, cmd);
466+
std::string cmdStr;
467+
468+
ozVSGet(vm, cmd, cmdBufSize, cmdStr);
469+
status = build(vm, system(cmdStr.c_str()));
470+
}
471+
};
472+
460473
// Socket I/O
461474

462475
private:

0 commit comments

Comments
 (0)