[SERVER-5154] Shell script should be able to receive command line arguments Created: 01/Mar/12 Updated: 25/Oct/21 Resolved: 25/Oct/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.1.0 |
| Fix Version/s: | features we're not sure of |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Srimonti Karmakar | Assignee: | Geert Bosch |
| Resolution: | Won't Do | Votes: | 5 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All |
||
| Participants: |
| Description |
|
It should be possible to run ./mongo dbname myscript.js --myarg value where myarg would be passed to myscript as a command line argument. |
| Comments |
| Comment by Srimonti Karmakar [ 03/Mar/12 ] |
|
The feature request suggests use of ordering to distinguish between arguments to be passed to the script versus options set for the shell. Since the structure is adding args for the script through should able to detect correct vs incorrect $ ./mongo --host myDataBaseHost foo.js #correct |
| Comment by Andy Schwerin [ 02/Mar/12 ] |
|
A typical approach to the "duped parameter names" problem on *nix systems is to make use of ordering. Arguments before the script go to the interpreter, and those after go to the script's own "ARGV" array, or equivalent. |
| Comment by Tad Marshall [ 02/Mar/12 ] |
|
Discussed in http://groups.google.com/group/mongodb-user/browse_thread/thread/fa93bb09e73a4a37 My comment: If the intent is that --myarg is the parameter name, then this would be hard to do this way without losing the ability to reject invalid command line arguments. $ ./mongo --host myDataBaseHost foo.js # connect to host myDataBaseHost We also have the risk of breaking existing parameter-passing command lines if we introduce a new command line option. |