Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • The "first and third but not second" argument applies equally to commands that shift left; as soon as you start needing arbitrary subsets of the arguments you should be using flags. That doesn't mean that programs with optional positional parameters are fundamentally flawed. Commented Apr 1, 2016 at 0:45
  • @dimo414 I'm well aware of that. As you can see I've now included the code example using flags. I just decided to post my answer without waiting until I finished the second example, since it's still useful without. Nothing wrong at all with optional positional parameters; I would happily use either of the code examples above in production scenarios. Commented Apr 1, 2016 at 0:52