diff options
author | Tim Potter <tpot@samba.org> | 2005-06-04 03:51:38 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:17:33 -0500 |
commit | 32f2e9806b267782125fed3a6162ea895e634eef (patch) | |
tree | 15f2ae5a75ebd447b75d56114b05b4a19b2ad4e9 /source4/scripting | |
parent | d6555cadb7015d407a2a17538d8a1ccd073a41e6 (diff) | |
download | samba-32f2e9806b267782125fed3a6162ea895e634eef.tar.gz samba-32f2e9806b267782125fed3a6162ea895e634eef.tar.bz2 samba-32f2e9806b267782125fed3a6162ea895e634eef.zip |
r7263: Exit smbscript with the intepreter return value (defaults to 0).
Change the exit value for an exception, usage error and other non-js
errors to 127 which is kinda like the return value for the system(3)
function.
(This used to be commit c77a232b1152a27e2d8ffb719aefba6c6b2ba6df)
Diffstat (limited to 'source4/scripting')
-rw-r--r-- | source4/scripting/ejs/smbscript.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index 4bde40a955..02a3aff28e 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - Standalone client for ESP scripting. + Standalone client for ejs scripting. Copyright (C) Tim Potter <tpot@samba.org> 2005 @@ -27,7 +27,7 @@ void ejs_exception(const char *reason) { fprintf(stderr, "smbscript exception: %s", reason); - exit(1); + exit(127); } int main(int argc, const char *argv[]) @@ -39,12 +39,12 @@ void ejs_exception(const char *reason) size_t script_size; TALLOC_CTX *mem_ctx = talloc_new(NULL); const char **argv_list = NULL; - struct MprVar v; - int i; + struct MprVar v, *return_var; + int exit_status, i; if (argc < 2) { fprintf(stderr, "Usage: %s <scriptfile>\n", argv[0]); - exit(1); + exit(127); } setup_logging(argv[0],DEBUG_STDOUT); @@ -52,7 +52,7 @@ void ejs_exception(const char *reason) if (!lp_load(dyn_CONFIGFILE, False, False, False)) { fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", argv[0], dyn_CONFIGFILE); - exit(1); + exit(127); } load_interfaces(); @@ -62,7 +62,7 @@ void ejs_exception(const char *reason) if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " "EJ subsystem\n"); - exit(1); + exit(127); } smb_setup_ejs_functions(); @@ -70,7 +70,7 @@ void ejs_exception(const char *reason) if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) { fprintf(stderr, "smbscript: ejsOpenEngine(): unable to " "initialise an EJS engine\n"); - exit(1); + exit(127); } /* setup ARGV[] in the ejs environment */ @@ -98,12 +98,15 @@ void ejs_exception(const char *reason) /* run the script */ if (ejsEvalScript(eid, script, &result, &emsg) == -1) { fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg); - exit(1); + exit(127); } + return_var = ejsGetReturnValue(eid); + exit_status = return_var->integer; + ejsClose(); talloc_free(mem_ctx); - return 0; + return exit_status; } |