diff --git a/Global.cpp b/Global.cpp index 05fbc56..49e6847 100644 --- a/Global.cpp +++ b/Global.cpp @@ -7,7 +7,7 @@ namespace jet { - Global::Global() { + Global::Global(char **envp) : envp(envp) { } diff --git a/Global.h b/Global.h index 9a055e3..58a4ffe 100644 --- a/Global.h +++ b/Global.h @@ -11,7 +11,7 @@ namespace jet { class Global { public: - Global(); + Global(char **envp); virtual ~Global(); void dump(); @@ -30,7 +30,8 @@ namespace jet { std::map sessions; std::map headers; std::map tags; - coreutils::MString lastConverted; + coreutils::MString lastConverted; + char **envp; }; diff --git a/__call.cpp b/__call.cpp index f3e8b5d..5772756 100644 --- a/__call.cpp +++ b/__call.cpp @@ -33,7 +33,7 @@ namespace jet { dup2(fdo[1], 1); if(variableDefined("input")) { resolveKeyword("input"); - coreutils::ZString input(variables[variables["input"]]); + coreutils::ZString input(variables["input"]); pipe(fdi); if(fork() == 0) { close(fdi[0]); @@ -41,12 +41,12 @@ 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 = execvpe(variables["pgm"].c_str(), argv, global.envp); close(fdo[1]); - exit(rc); + exit(errno); } close(fdo[1]); if(variableDefined("name")) { @@ -63,9 +63,10 @@ namespace jet { } else out.read(fdo[0]); waitpid(pid, &status, 0); - if(variableDefined("status")) - resolveKeyword("status"); - global.variables[variables["status"]] = (status >> 8 & 255); + if(variableDefined("error")) { + resolveKeyword("error"); + global.variables[variables["error"]] = (status >> 8 & 255); + } } } diff --git a/jet-2.0.cpp b/jet-2.0.cpp index 2b14ce5..0ea6de0 100644 --- a/jet-2.0.cpp +++ b/jet-2.0.cpp @@ -5,14 +5,14 @@ #include "Exception.h" #include "__jet.h" -int main(int argc, char **argv) { +int main(int argc, char **argv, char **envp) { coreutils::File script(argv[1]); script.read(); coreutils::ZString data = script.asZString(); data.goeol(); - jet::Global global; + jet::Global global(envp); try { coreutils::MString out; diff --git a/tests/testcall.jet b/tests/testcall.jet index c993031..be1f8bb 100755 --- a/tests/testcall.jet +++ b/tests/testcall.jet @@ -1,8 +1,8 @@ #!../jet-2.0 - + test1=$[test1] name1=#[localname] -status=$[stat] +error=$[error]