svn commit: samba r7263 - in branches/SAMBA_4_0/source/scripting/ejs: .

tpot at samba.org tpot at samba.org
Sat Jun 4 03:51:39 GMT 2005


Author: tpot
Date: 2005-06-04 03:51:38 +0000 (Sat, 04 Jun 2005)
New Revision: 7263

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7263

Log:
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.

Modified:
   branches/SAMBA_4_0/source/scripting/ejs/smbscript.c


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/smbscript.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-06-04 03:35:38 UTC (rev 7262)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbscript.c	2005-06-04 03:51:38 UTC (rev 7263)
@@ -1,7 +1,7 @@
 /* 
    Unix SMB/CIFS implementation.
 
-   Standalone client for ESP scripting.
+   Standalone client for ejs scripting.
 
    Copyright (C) Tim Potter <tpot at 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	/* 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;
 }



More information about the samba-cvs mailing list