#getopt — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #getopt, aggregated by home.social.
-
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... -
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... -
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... -
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... -
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.
https://youtu.be/PAw478XJYWI#FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator
-
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.
https://youtu.be/PAw478XJYWI#FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator
-
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.
https://youtu.be/PAw478XJYWI#FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator
-
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.
https://youtu.be/PAw478XJYWI#FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator
-
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.
https://youtu.be/PAw478XJYWI#FamilySizeVM #emudev #NESdev #CommandLine #CLI #musl #getopt #timelapse #emulator
-
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.
-
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 .
-
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.
https://groups.google.com/g/comp.os.os2.utilities/c/415LDKL3_Lw/m/P9tPDLd7VAUJ
I made use of what my own tools could do. (-:
-
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.
-
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.
-
Having perpetrated some shell scripting, I naturally got irritated at the limitations and having to drive #getopt/#getopts by hand. So I am going to write my own replacement, just like everyone else. You may now call me an idiot.
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #lua
#programming #programacion #getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--lua
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #java
#programming #programacion #ARGV #Getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--java
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #tcl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--tcl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #tcl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--tcl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #tcl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--tcl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #tcl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-11-parametros-linea-de-comandos--tcl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #bash
#programming #programacion #cmdline #ARGV #Getopt #ShellScripts #shell
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--bash
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Ruby
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--ruby
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Ruby
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--ruby
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Ruby
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--ruby
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Ruby
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-10-parametros-linea-de-comandos--ruby
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Perl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-09-parametros-linea-de-comandos--perl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Perl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-09-parametros-linea-de-comandos--perl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Perl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-09-parametros-linea-de-comandos--perl
-
#SolucionarioDelProgramador #GNU_linux : Parámetros línea de Comandos en #Perl
#programming #programacion #cmdline #ARGV #Getopt
https://ibolcode.net/roor/2025-09-parametros-linea-de-comandos--perl
-
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. (-:
https://svnweb.freebsd.org/csrg/bin/ps/ps.c?r1=40257&r2=40675#l303
https://svnweb.freebsd.org/csrg/bin/ps/ps.1?r1=44281&r2=45158
-
@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...
-
@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.
-
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 ( https://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!
-
#optparse is a #publicdomain dependencyless #getopt.
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 🔗️: https://github.com/skeeto/optparse