Bug 675269: shell arguments bound to global |arguments|. (r=dvander)

This commit is contained in:
Chris Leary 2011-08-15 13:57:53 -07:00
Родитель 97e715bf52
Коммит c43c4d1fb4
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -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;
}