Setup proper keyword resolution for call tag.
This commit is contained in:
parent
6da620971e
commit
069fb9c9f3
19
__call.cpp
19
__call.cpp
@ -14,13 +14,15 @@ namespace jet {
|
|||||||
throw coreutils::Exception("call tag cannot have a container.");
|
throw coreutils::Exception("call tag cannot have a container.");
|
||||||
if(!variableDefined("pgm"))
|
if(!variableDefined("pgm"))
|
||||||
throw coreutils::Exception("pgm keyword must be specified.");
|
throw coreutils::Exception("pgm keyword must be specified.");
|
||||||
|
resolveKeyword("pgm");
|
||||||
argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
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) {
|
for(ix = 1; ix <= 50; ++ix) {
|
||||||
coreutils::MString arg("arg");
|
coreutils::MString arg("arg");
|
||||||
arg << ix;
|
arg << ix;
|
||||||
if(variableDefined(arg))
|
if(variableDefined(arg)) {
|
||||||
|
resolveKeyword(arg);
|
||||||
argv[ix] = variables[arg].c_str();
|
argv[ix] = variables[arg].c_str();
|
||||||
else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
argv[ix] == NULL;
|
argv[ix] == NULL;
|
||||||
@ -30,6 +32,7 @@ namespace jet {
|
|||||||
close(fdo[0]);
|
close(fdo[0]);
|
||||||
dup2(fdo[1], 1);
|
dup2(fdo[1], 1);
|
||||||
if(variableDefined("input")) {
|
if(variableDefined("input")) {
|
||||||
|
resolveKeyword("input");
|
||||||
coreutils::ZString input(variables[variables["input"]]);
|
coreutils::ZString input(variables[variables["input"]]);
|
||||||
pipe(fdi);
|
pipe(fdi);
|
||||||
if(fork() == 0) {
|
if(fork() == 0) {
|
||||||
@ -46,12 +49,22 @@ namespace jet {
|
|||||||
exit(rc);
|
exit(rc);
|
||||||
}
|
}
|
||||||
close(fdo[1]);
|
close(fdo[1]);
|
||||||
if(variableDefined("name"))
|
if(variableDefined("name")) {
|
||||||
|
resolveKeyword("name");
|
||||||
|
if(!variableDefined("scope") && (variables["scope"] == "global"))
|
||||||
global.variables[variables["name"]].read(fdo[0]);
|
global.variables[variables["name"]].read(fdo[0]);
|
||||||
|
else if(variables["scope"] == "local")
|
||||||
|
parent->variables[variables["name"]].read(fdo[0]);
|
||||||
|
else if(variables["scope"] == "parent")
|
||||||
|
parent->parent->variables[variables["name"]].read(fdo[0]);
|
||||||
else
|
else
|
||||||
|
throw coreutils::Exception("scope value is not valid.");
|
||||||
|
|
||||||
|
} else
|
||||||
out.read(fdo[0]);
|
out.read(fdo[0]);
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
if(variableDefined("status"))
|
if(variableDefined("status"))
|
||||||
|
resolveKeyword("status");
|
||||||
global.variables[variables["status"]] = (status >> 8 & 255);
|
global.variables[variables["status"]] = (status >> 8 & 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user