From 59db38b83f7377c6be3d926b4cadfc5c1b4aa395 Mon Sep 17 00:00:00 2001 From: Chris Leary Date: Mon, 15 Aug 2011 13:57:53 -0700 Subject: [PATCH] Bug 675269: shell arguments bound to global |arguments|. (r=dvander) --- js/src/shell/js.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index c229bb1808bd..1691872dd807 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5030,7 +5030,14 @@ BindScriptArgs(JSContext *cx, JSObject *obj, OptionParser *op) JSObject *scriptArgs = JS_NewArrayObject(cx, 0, NULL); if (!scriptArgs) return false; - if (!JS_DefineProperty(cx, obj, "scriptArgs", OBJECT_TO_JSVAL(scriptArgs), NULL, NULL, 0)) + + /* + * Script arguments are bound as a normal |arguments| property on the + * global object. It has no special significance, like |arguments| in + * function scope does -- this identifier is used de-facto across shell + * implementations, see bug 675269. + */ + if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(scriptArgs), NULL, NULL, 0)) return false; for (size_t i = 0; !msr.empty(); msr.popFront(), ++i) { @@ -5350,7 +5357,7 @@ main(int argc, char **argv, char **envp) #endif || !op.addOptionalStringArg("script", "A script to execute (after all options)") || !op.addOptionalMultiStringArg("scriptArgs", - "String arguments to bind as |scriptArgs| in the " + "String arguments to bind as |arguments| in the " "shell's global")) { return EXIT_FAILURE; }