Closed
Bug 685025
Opened 14 years ago
Closed 14 years ago
Shell should be able to read from stdin
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla9
People
(Reporter: cdleary, Assigned: cdleary)
Details
Attachments
(1 file)
1.67 KB,
patch
|
brendan
:
review+
|
Details | Diff | Splinter Review |
$ ./js - < test2.js
Hoo!
$ ./js -f test.js - < test2.js
Whoo
Hoo!
Attachment #558657 -
Flags: review?(brendan)
Comment 1•14 years ago
|
||
Comment on attachment 558657 [details] [diff] [review]
Solo dash argument.
># HG changeset patch
># Parent 6a4e5dbe0d64d7646306b4c9fc50a69b29631551
>
>diff --git a/js/src/shell/jsoptparse.cpp b/js/src/shell/jsoptparse.cpp
>--- a/js/src/shell/jsoptparse.cpp
>+++ b/js/src/shell/jsoptparse.cpp
>@@ -373,19 +373,21 @@ OptionParser::parseArgs(int inputArgc, c
> /* Permit a "no more options" capability, like |--| offers in many shell interfaces. */
> bool optionsAllowed = true;
>
> for (size_t i = 1; i < argc; ++i) {
> char *arg = argv[i];
> Result r;
> if (arg[0] == '-' && optionsAllowed) {
> /* Option. */
>- size_t arglen = strlen(arg);
>- if (arglen < 2) /* Do not permit solo dash option. */
>- return error("Invalid dash option");
>+ if (arg[1] == '\0') {
>+ /* Solo dash option is actually a 'stdin' argument. */
>+ r = handleArg(argc, argv, &i, &optionsAllowed);
Note statement immediately above.
>+ goto have_result;
>+ }
>
> Option *opt;
> if (arg[1] == '-') {
> /* Long option. */
> opt = findOption(arg + 2);
> if (!opt)
> return error("Invalid long option: %s", arg);
> } else {
>@@ -397,16 +399,17 @@ OptionParser::parseArgs(int inputArgc, c
> return error("Invalid short option: %s", arg);
> }
>
> r = handleOption(opt, argc, argv, &i, &optionsAllowed);
> } else {
> /* Argument. */
> r = handleArg(argc, argv, &i, &optionsAllowed);
Same as this basic block.
> }
>+ have_result:
Succeeded by what's at this label, so instead of duplicating the r = handleArg(...) call and using a goto, how about:
if (arg[0] == '-' && arg[1] != '\0' && optionsAllowed) {
up front, and unify the handleArg call (and avoid the strlen < 2 test).
r=me with that. Thanks,
/be
Attachment #558657 -
Flags: review?(brendan) → review+
Assignee | ||
Updated•14 years ago
|
Whiteboard: [inbound]
Comment 2•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla9
You need to log in
before you can comment on or make changes to this bug.
Description
•