We used to expose the commandline arguments as |arguments| in the js shell, but recently stopped doing so. However, at least the v8 shell does this, perhaps in order to emulate our original behavior. Would be nice to restore |arguments| so projects using multiple js shells don't need to check for |scriptArgs| as well as |arguments|.
Another issue (tell me if you want a separate bug): It is no longer possible to pass arguments into JS that start with '-'. For example, this will work
js test.js arg1
(arg1 is passed to the script) but this will fail
js test.js -arg1
(the js engine gives an error about an unknown arg). This used to work though.
v8 requires that arguments to the js engine and arguments to the js script be separated by '--' (like getopt does), so
js test.js -- -arg1
would work there, and there is no ambiguity to figure out. Maybe that makes sense to do as well?
(In reply to comment #1)
> v8 requires that arguments to the js engine and arguments to the js script
> be separated by '--' (like getopt does), so
> js test.js -- -arg1
Does that work when the shell is used in the shebang line? That was a use case for the existing form raised in the newsgroup.
I seem to get errors with any parameters (-- or otherwise) in the shebang line with v8,
> #!/home/alon/Dev/v8/d8 test.js foo
> Error reading 'test.js foo'
so not sure what the use case is there.
(In reply to comment #3)
> I seem to get errors with any parameters (-- or otherwise) in the shebang
> line with v8,
Parameters aren't place in the shebang line -- the shebang line indicates an interpreter to the operating system, and I think the subsequent parameters are passed as arguments to the interpreter process.
$ ./foo.js these are some args
["these", "are", "some", "args"
I can't seem to get things to work in the shebang line - I never messed with this stuff before. But I don't understand the background, I guess, why would re-allowing parameters that start with "-" be a problem for shebang?
Created attachment 553221 [details] [diff] [review]
scriptArgs becomes arguments again