Setup proper keyword resolution for call tag.

This commit is contained in:
Brad Arant 2024-11-11 08:46:00 -08:00
parent 6da620971e
commit 069fb9c9f3

View File

@ -14,13 +14,15 @@ namespace jet {
throw coreutils::Exception("call tag cannot have a container.");
if(!variableDefined("pgm"))
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].
for(ix = 1; ix <= 50; ++ix) {
coreutils::MString arg("arg");
arg << ix;
if(variableDefined(arg))
if(variableDefined(arg)) {
resolveKeyword(arg);
argv[ix] = variables[arg].c_str();
else
} else
break;
}
argv[ix] == NULL;
@ -30,6 +32,7 @@ namespace jet {
close(fdo[0]);
dup2(fdo[1], 1);
if(variableDefined("input")) {
resolveKeyword("input");
coreutils::ZString input(variables[variables["input"]]);
pipe(fdi);
if(fork() == 0) {
@ -46,12 +49,22 @@ namespace jet {
exit(rc);
}
close(fdo[1]);
if(variableDefined("name"))
global.variables[variables["name"]].read(fdo[0]);
else
if(variableDefined("name")) {
resolveKeyword("name");
if(!variableDefined("scope") && (variables["scope"] == "global"))
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
throw coreutils::Exception("scope value is not valid.");
} else
out.read(fdo[0]);
waitpid(pid, &status, 0);
if(variableDefined("status"))
resolveKeyword("status");
global.variables[variables["status"]] = (status >> 8 & 255);
}