Closed
Bug 675269
Opened 14 years ago
Closed 14 years ago
restore |arguments| in javascript shell
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla8
People
(Reporter: azakai, Assigned: cdleary)
Details
(Whiteboard: [inbound])
Attachments
(1 file)
|
2.23 KB,
patch
|
dvander
:
review+
|
Details | Diff | Splinter Review |
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|.
| Reporter | ||
Updated•14 years ago
|
Assignee: general → cdleary
| Reporter | ||
Comment 1•14 years ago
|
||
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?
| Assignee | ||
Comment 2•14 years ago
|
||
(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.
| Reporter | ||
Comment 3•14 years ago
|
||
I seem to get errors with any parameters (-- or otherwise) in the shebang line with v8,
> #!/home/alon/Dev/v8/d8 test.js foo
gives me
> Error reading 'test.js foo'
so not sure what the use case is there.
| Assignee | ||
Comment 4•14 years ago
|
||
(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.
<<EOF
#!/usr/bin/env js
print(uneval(scriptArgs))
EOF
$ ./foo.js these are some args
["these", "are", "some", "args"
| Reporter | ||
Comment 5•14 years ago
|
||
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?
| Assignee | ||
Comment 6•14 years ago
|
||
Attachment #553221 -
Flags: review?(dvander)
Updated•14 years ago
|
Attachment #553221 -
Flags: review?(dvander) → review+
| Assignee | ||
Updated•14 years ago
|
Whiteboard: [inbound]
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
You need to log in
before you can comment on or make changes to this bug.
Description
•