diff --git a/__system.cpp b/__system.cpp
index 626d2e6..85435be 100644
--- a/__system.cpp
+++ b/__system.cpp
@@ -11,25 +11,16 @@ namespace jet {
__system::__system(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent) : Tag(in, parentOut, global, parent) {
if(hasContainer)
throw coreutils::Exception("system tag cannot have a container.");
- if(!variableDefined(coreutils::ZString("pgm")))
- throw coreutils::Exception("pgm keyword must be specified.");
- argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
- for(ix = 1; ix <= 50; ++ix) {
- coreutils::MString arg("arg");
- arg << ix;
- if(variableDefined(arg))
- argv[ix] = variables[arg].c_str();
- else
- break;
- }
- argv[ix] == NULL;
+ if(!variableDefined(coreutils::ZString("cmd")))
+ throw coreutils::Exception("cmd keyword must be specified.");
pipe(fdo);
pid = fork();
if(pid == 0) {
close(fdo[0]);
dup2(fdo[1], 1);
if(variableDefined("input")) {
- coreutils::ZString input(variables[variables["input"]]);
+ resolveKeyword("input");
+ coreutils::ZString input(variables["input"]);
pipe(fdi);
if(fork() == 0) {
close(fdi[0]);
@@ -37,12 +28,11 @@ namespace jet {
close(fdi[1]);
exit(0);
}
- close(fdi[0]);
+ close(fdi[1]);
dup2(fdi[0], 0);
}
- rc = execve(variables["pgm"].c_str(), argv, NULL);
+ rc = system(variables["cmd"].c_str());
close(fdo[1]);
- std::cout << "rc: " << rc << std::endl;
exit(rc);
}
close(fdo[1]);
@@ -51,7 +41,9 @@ namespace jet {
else
out.read(fdo[0]);
waitpid(pid, &status, 0);
- std::cout << "status: " << status << std::endl;
+ if(variableDefined("status"))
+ resolveKeyword("status");
+ global.variables[variables["status"]] = (status >> 8 & 255);
}
}
diff --git a/tests/testcall.jet b/tests/testcall.jet
new file mode 100755
index 0000000..c993031
--- /dev/null
+++ b/tests/testcall.jet
@@ -0,0 +1,8 @@
+#!../jet-2.0
+
+
+
+test1=$[test1]
+name1=#[localname]
+status=$[stat]
+
diff --git a/tests/testsystem.jet b/tests/testsystem.jet
new file mode 100755
index 0000000..8de0704
--- /dev/null
+++ b/tests/testsystem.jet
@@ -0,0 +1,8 @@
+#!../jet-2.0
+
+
+
+test1=$[test1]
+name1=#[localname]
+status=$[stat]
+