diff --git a/__call.cpp b/__call.cpp index 9ce2f60..d960edf 100644 --- a/__call.cpp +++ b/__call.cpp @@ -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); }