5 ms·
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 allowin
by jiehong 4y ago
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)
- teddyh 4y agoOr ps, with its BSD and SysV variants. On Linux, the most widely used version of ps uses BSD semantics when using options without a dash, and SysV semantics for dashed options. Thus, both BSD “ps aux” and SysV “ps -fel” work.
- LeoPanthera 4y ago> One oddity not explained is tar allowing multi options crammed together without any dash, that nobody can ever remember (eg. tar xvf archive.tar) This is a BSDism, and it's deprecated even there. bsdtar allows it for compatibility with old scripts. GNUtar has long-switches for all options, which makes it considerably easier to use and understand, for example: gtar --create --file etc.tar --verbose /etc
- nsajko 4y ago> This is a BSDism No, it was like that when Tar was first introduced, as part of Seventh Edition Unix: https://man.cat-v.org/unix_7th/1/tar https://man.cat-v.org/unix_7th/1/tar https://en.wikipedia.org/wiki/Tar_(computing) https://en.wikipedia.org/wiki/Tar_(computing)
- eesmith 4y agoSee also "tap" from v1, to "manipulate DECtape", described at http://www.bitsavers.org/pdf/bellLabs/unix/UNIX_ProgrammersManual_Nov71.pdf http://www.bitsavers.org/pdf/bellLabs/unix/UNIX_ProgrammersM... , p94 of the pdf: > tap [key] [name ...] > The function portion of the key is specified by one of the following letters ... For example, "x" to extract. > The following characters may be used in addition to the letter which selects the function desired For example, "v" for verbose.
- elteto 4y ago> that nobody can ever remember These have gone a long way for me: tar xzf <in> eXtract Zipped File tar czf <out> <in> Create Zipped File Anything more complicated and I have to google.
- aendruk 4y agoNo need for the mnemonic device when you can literally type “--extract --gzip --file”, which reads as a sentence and has no trouble adapting to --xz or --zstd.
- Macha 4y agoThe `-z` on extract is not needed on basically most modern tar implementations (OpenBSD's is I believe the one outlier). tar -xf foo.tar.gz (or .xz, .bz2, .zst, etc.) will work, auto detect the archive type and extract.
- yourad_io 4y agoOh this is great, I remember z for gzip but always have to look up J vs j for bzip2/xz
- cb321 4y agoWith https://github.com/c-blake/nio/blob/main/utils/catz.nim https://github.com/c-blake/nio/blob/main/utils/catz.nim you can get similar format agnostic decoding/decompression not just in tar but in any pipeline context based on magic numbers, not filename extensions and even doing the copy loop needed for unseekable inputs to replace the early read -- e.g. cat foo.gz|catz|less works..
- 1vuio0pswjnm7 4y agoOpenBSD, which is a fork of NetBSD, is not the only "outlier".^1 For many years, NetBSD tar has autodetected bzip2 compression. tar xzf 1.tar.bz2 will work on gzip as well as bzip2. Whereas GNU tar still requires "j" instead^2 tar xjf 1.tar.bz2 1. For example, FreeBSD or MacOS tar is BSD tar. It will autodetect bzip2 compression. 2. The GNU tar included with VoidLinux still requires z or j. The pax(1) utility is the POSIX solution to these incompatibilities.
- kergonath 4y ago> gtar --create --file etc.tar --verbose /etc That’s considerably more cumbersome than tar -cvf.
- 1vuio0pswjnm7 4y ago"... that nobody can ever remember." Perhaps it comes down to what programs one uses routinely. Typing "tar xzf" multiple times per week I am unlikely to ever forget it.