Live data from Hacker News

Unix command line conventions over time

blog.liw.fi

1–10 of 222 posts

Re: Unix command line conventions over time

#2
I don't think this is entirely wrong, but it's drawing a bit of a long bow. The getopt wars on Usenet were interesting, shar files flew around before we settled on gnu's take on things.

I think distinct shell commands are good. MH is my go to instance of doing this right (it's still under active development)

Re: Unix command line conventions over time

#4
Unix history is always fascinating.

>None of this explains dd.

This one really made me think. I have never thought about dd before. Although I have wondered about other commands. Perhaps the author should also have added some command options not requiring a minus prefix, e.g. tar, ps.

The manpage [0] reads:

In the first (legacy) form, all option flags except for -C and -I must be contained within the first argument to tar and must not be prefixed by a hyphen (`-'). Option arguments, if any, are processed as subsequent arguments to tar and are processed in the order in which their corresponding option flags have been presented on the command line. In the second and preferred form, option flags may be given in any order and are immediately followed by their corresponding option argument values.

[0]: http://man.openbsd.org/tar

Re: Unix command line conventions over time

#6
And then there is also the case of CLIs that aren’t written in C: they don’t get the benefits of a unified getopts lib.

One oddity not explained is tar allowing multi options crammed together without any dash, that nobody can ever remember (eg. tar xvf archive.tar)

Re: Unix command line conventions over time

#9
The GNU conventions are terribly convenient. If we were redesigning it from scratch, I'd like to keep all of them except for removing duplicated functionality. One of --long x and --long=x have to go, and that means we only can keep --long=x. And so on.

Re: Unix command line conventions over time

#10
post #8

What is the getopt equivalent for sub command handling? Or get opt can parse subcommads too?

You probably want argp_parse(): https://www.gnu.org/software/libc/manual/html_mono/libc.html...

See especially getsubopt(): https://www.gnu.org/software/libc/manual/html_mono/libc.html...

Post reply on HN