4 ms·
Almost totally unrelated, but taking the opportunity to rant. If you use OS X, your getopt is fully POSIX compliant (as are many BSDs, I think), unlike most Lin
by codezero 11y ago
Almost totally unrelated, but taking the opportunity to rant. If you use OS X, your getopt is fully POSIX compliant (as are many BSDs, I think), unlike most Linux distributions. This means globs (files arguments) must come after optionals.
For example:
ls -la * .txt
OK
ls * .txt -la
Not OK
This drives me mad.
- _ZeD_ 11y agouhm, sorry? shouldn't glob be handled by the shell? I mean, the "ls" program does not handle literally '*.txt', but "foo.txt bar.txt baz.txt"
- codezero 11y agoRight but ls calls getopt – and determines the meaning of the values provided. After a glob, of say, * .txt, and let's say there are a.txt, b.txt and c.txt, if I call ls * .txt -ltra it expands to ls a.txt b.txt c.txt -ltra In POSIX it expects options to appear before files, see: https://en.wikipedia.org/wiki/Getopt#Example_1_.28using_POSIX_standard_getopt.29 https://en.wikipedia.org/wiki/Getopt#Example_1_.28using_POSI... Trust me, I wish this were not adhered to, but it is.
- cperciva 11y agoYes, I deliberately did not implement that GNU bug. I also avoided implementing the --prefix-of-long-option bug.
- codezero 11y agoIt makes me very happy that you refer to this as a bug :)