home.social

#getopt — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #getopt, aggregated by home.social.

  1. My #emulator takes a ROM filename on the #CommandLine, among other options. I use the #musl library's #getopt to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python. youtu.be/PAw478XJYWI #FamilySizeVM #emudev #CLI #timelapse #emulator

    Parsing a command line in C is...

  2. My #emulator takes a ROM filename on the #CommandLine, among other options. I use the #musl library's #getopt to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python. youtu.be/PAw478XJYWI #FamilySizeVM #emudev #CLI #timelapse #emulator

    Parsing a command line in C is...

  3. My #emulator takes a ROM filename on the #CommandLine, among other options. I use the #musl library's #getopt to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python. youtu.be/PAw478XJYWI #FamilySizeVM #emudev #CLI #timelapse #emulator

    Parsing a command line in C is...

  4. My #emulator takes a ROM filename on the #CommandLine, among other options. I use the #musl library's #getopt to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python. youtu.be/PAw478XJYWI #FamilySizeVM #emudev #CLI #timelapse #emulator

    Parsing a command line in C is...

  5. My emulator takes a path to a ROM image on the command line, among other options. I use the musl library's getopt_long function to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python.
    youtu.be/PAw478XJYWI

    #FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator

  6. My emulator takes a path to a ROM image on the command line, among other options. I use the musl library's getopt_long function to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python.
    youtu.be/PAw478XJYWI

    #FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator

  7. My emulator takes a path to a ROM image on the command line, among other options. I use the musl library's getopt_long function to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python.
    youtu.be/PAw478XJYWI

    #FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator

  8. My emulator takes a path to a ROM image on the command line, among other options. I use the musl library's getopt_long function to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python.
    youtu.be/PAw478XJYWI

    #FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator

  9. My emulator takes a path to a ROM image on the command line, among other options. I use the musl library's getopt_long function to parse the command in C. It makes me appreciate the libraries that come with newer languages like Python.
    youtu.be/PAw478XJYWI

    #FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator

  10. @gumnos

    I am the voice of experience:

    @rl_dane was talking about getopt yesterday, and I found that I was running a /usr/local/bin/getopt from ports with very different handling of '--' (alluded to by @steeph , so I had been checking it out) to the actual #FreeBSD /usr/bin/getopt on the machine.

    I wouldn't be surprised if I'm running a different /usr/bin/grep (I checked that.) to you. "I'm using FreeBSD grep." has famously been two entirely different programs over the years.

    #getopt #grep

  11. @ianthetechie

    I was about to write the same thing.

    And as @steeph pointed out, getopt in shell script does not allow one to do several things, including take advantage of the Z shell's ability to automatically construct command-line completions for anything that supports --help .

    @rl_dane
    #getopt #UnixShells #zsh

  12. @ska

    My schools did not teach C or any language like it.

    I learned about -- and #getopt from a combination of FidoNet, Usenet, and a 1985 book on Unix by Eric Foxley.

    The habit of using -- probably cemented when I wrote a load of command-line utilities for DOS and OS/2 in the 1990s which all supported an end-of-options marker in their command-tail parsing library.

    groups.google.com/g/comp.os.os

    I made use of what my own tools could do. (-:

    @cazabon
    #os2clu #dosclu

  13. @jas

    My first suspect for a #login not supporting -- would be something with a 1980s history pre-dating standard #getopt, such as Solaris, which is ironic given that #inetutils has its only -- present in conditionally compiled code targetting Solaris.

    #FreeBSD, #NetBSD, and #OpenBSD login all use getopt(), pervasive in these worlds for decades, as do the util-linux login (used by Debian et al.), and the #Illumos and #BusyBox logins.

    #suckless login supports -- via ARGBEGIN.

    @ska @cazabon

  14. @ska

    Looking at the commit and the code as it still stands today, it is interesting that only on Solaris does it even try to use -- in the arguments to login to signal the end of options, and even then only in limited circumstances.

    #FreeBSD telnetd, for comparison, always puts -- in before the supplied account name.

    I wonder how long it will be before the lesson is properly learned.

    @jas
    #getopt #login #telnetd #inetutils

  15. Having perpetrated some shell scripting, I naturally got irritated at the limitations and having to drive /#getopts by hand. So I am going to write my own replacement, just like everyone else. You may now call me an idiot.

  16. @Larvitz

    Three suggestions and three observations:

    1.

    FreeBSD ps switched to getopt() in 1990. The manual page has given that syntax for 35 years.

    It's a sad irony of Linux that the "procps" ps cloned a supposed BSD ps that was not like that by that point and had not been since before Linux existed.

    So ps -aux rather than ps aux.

    Get the Linux people on board with getopt(), and make Marc Teitelbaum proud. (-:

    svnweb.freebsd.org/csrg/bin/ps

    svnweb.freebsd.org/csrg/bin/ps

    #FreeBSD #ps #getopt

  17. @nixCraft Not quite a by-product of the Unix wars, but the 4 or 5 or 6 different #getopt conventions are a blight on the Unix family.

    Accepting options after non-option arguments was always an abomination to me because of a) the ambiguity it creates and b) it broke exec-chaining, no doubt because the authors had never heard of it or didn't like the inventor (who is somewhat controversial)!

    Then we have --long-options and sometimes -long-options and sometimes +long-options.

    And let's not forget about booleans. Is it --flag false or --[no]flag or merely --flag with an implied true?

    It is so, so tempting to combine all of these and write the one-true-getopt function, excepting...

    xkcd.com/927/

  18. @davetron5000 @budu @pragprog Sorry it's out of print. Some tech books have a limited lifespan, although @OReillyMedia sometimes keeps "generally useful but potentially outdated" stuff available for a long time, e.g. I think they still have the original Ruby book from Matz available, which was written for #RubyLang 1.8 or 1.9 and isn't fully applicable to Ruby 3.2.2. 🤷

    #CLI argument parsing can be challenging no matter what you use. #Fishshell #argparse has a lot of limitations cf. GNU #getopt.

  19. For example: I wanna write a easy-to-write & read #commandline / #cli option-parser for #cpp where you dont need to know how exactly #getopt works and what global variables & states it has.

    One of the best other libraries out there for such stuff is #picocli ( picocli.info/ ). So naturally I wanna build something similar in #cpp .

    But theres soooo many problems: bc c++ dosnt has real generics, only templates, there is ofc no typeerasure, meaning that I constantly need to pass around all template params. Wich means that theres no easy way having a type `Option<Cmd>` (options for a specific command), inside a list like `std::vector`! Even tho the storage space of a pointer is the same: 8 bytes, and thanks to virtual methods calling the right methods isnt a problem either!

  20. is a dependencyless .

    optparse is a command line option parser that functions in a similar manner to getopt. optparse does not use global state, allowing for subcommands and restarting of the parser in a reliable way. optparse provides both short and long option parsing, option permuting, and capturable errors.

    Website 🔗️: github.com/skeeto/optparse