зеркало из https://github.com/mozilla/pjs.git
Bug 675269: shell arguments bound to global |arguments|. (r=dvander)
This commit is contained in:
Родитель
97e715bf52
Коммит
c43c4d1fb4
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче