3 ms·
> 5. Don’t have positional options. But also, don't conflate options with arguments. Options should be optional (the clue is in the name) and prefixed with - (
by rlpb 10y ago
> 5. Don’t have positional options.
But also, don't conflate options with arguments. Options should be optional (the clue is in the name) and prefixed with - (single letter options) or -- (long form options). Arguments are typically positional, but as the author says, they can become confusing if there are too many, or the ordering is non-obvious, in which case the syntax may need a rethink.
A blanket "don't use positional arguments" would be tedious though. For example, if I ignore what I say above, imagine having to type "cd --directory=foo" or "cp --source=foo --destination=bar" all the time.
- dllthomas 10y ago> "cp --source=foo --destination=bar" Cf. `dd if=foo of=bar` Not really disagreeing, just adding context.
- slrz 10y agoThen maybe one should also add the bit of context that dd's command line syntax was intended as a joke, a pun on some job control language of yore.
- dllthomas 10y agoOh, really? Interesting. While... odd, I always thought it appropriate to be extra explicit with dd, where for some common uses you've the chance of nuking the wrong disk. Do you know which job control language of yore?
- slrz 10y agoOS/360 JCL, apparently. At least Rob Pike wrote something to the effect on his Google+. dd is horrible on purpose. It's a joke about OS/360 JCL. But today it's an internationally standardized joke. I guess that says it all. How the hell does one direct-link to a G+ comment? Well, cllck the thing that says "View 384 bazillion previous comments" and then search for dd. https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp https://plus.google.com/+RobPikeTheHuman/posts/R58WgWwN9jp