-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: common
-
None
We recently had a question from a user who ran this command: mongorestore -h 127.0.0.1 -d backup -dir ~/backup/.
It's very subtle, but there is only one dash before dir. That means this is interpreted as the -d option followed by the string ir, as opposed to -dir (with two dashes).
There's a couple things that cause problems here:
- The argument parsing allows passing the -d option twice, but the last one wins. It would be much better to error out in this case.
- Accepting a short option like -d immediately followed by text without a space seems like a recipe for confusing, for exactly the case we see above.
We can fix this by doing the following:
1. Error when the same option is provided more than once, except for any option which is explicitly defined as allowing this (if we have any).
2. Do not allow a short option to be followed by its value without a space.