summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-29 11:58:14 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:12 -0500
commitf477a741293673adad784c55a749031a290bd072 (patch)
tree7d1cfe7dbe9d3da85ba051764decf8d49e6406e1
parent8f84f7cdecf12396eb5c1723e5e1ccf813cd9a51 (diff)
downloadsamba-f477a741293673adad784c55a749031a290bd072.tar.gz
samba-f477a741293673adad784c55a749031a290bd072.tar.bz2
samba-f477a741293673adad784c55a749031a290bd072.zip
r7075: added support for ARGV[] in ejs scripts
(This used to be commit 3db568eb6bb383c4c1e1fd0c7f043a9914dcc3cc)
-rw-r--r--source4/scripting/ejs/smbscript.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index c6b1b7a192..3378885147 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -37,8 +37,11 @@ void ejs_exception(const char *reason)
MprVar result;
char *emsg;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ const char **argv_list = NULL;
+ struct MprVar v;
+ int i;
- if (argc != 2) {
+ if (argc < 2) {
fprintf(stderr, "Usage: %s <scriptfile>\n", argv[0]);
exit(1);
}
@@ -67,6 +70,14 @@ void ejs_exception(const char *reason)
exit(1);
}
+ /* setup ARGV[] in the ejs environment */
+ for (i=2;i<argc;i++) {
+ argv_list = str_list_add(argv_list, argv[i]);
+ }
+ v = mprList("ARGV", argv_list);
+ mprCreateProperty(ejsGetGlobalObject(eid), "ARGV", &v);
+
+ /* run the script */
if (ejsEvalFile(eid, discard_const_p(char, argv[1]), &result,
&emsg) == -1) {
fprintf(stderr, "smbscript: ejsEvalScript(): %s\n", emsg);