getopt_long_only(3)
π getopt_long_only(3) β like, the manual page, bestie π
okay so this is getopt_long_only, straight outta the Library Functions Manual (yep, section 3, that's the "C library functions" section, iykyk). she parses long command-line options and she does it differently than her sister. let's get into it πΈ
β¨ NAME β¨
getopt_long_only β parse long command-line options π
π LIBRARY π
Standard C library, aka libc, link it with -lc. she's literally built in, no third-party nonsense π
π SYNOPSIS π
#define _GNU_SOURCE
#include <getopt.h>
int getopt_long_only(int argc, char *argv[],
const char *optstring,
const struct option *longopts, int *longindex);
β οΈ bestie look at that #define _GNU_SOURCE β you need it, she's a GNU girl, she does not show up without it π
π¦ DESCRIPTION π¦
so getopt_long_only() is basically getopt_long(3)'s twin sister, but with one chaotic little twist: both - AND -- can signal a long option. that's it, that's the whole plot. main character behavior honestly β¨
and here's the fine print: if an option starts with just a single - (so, not --) and it doesn't match a long option, but it does match a short one? then she goes "oh ok, we're doing short options now" and parses it as a short option instead. flexible queen π«Ά
π ATTRIBUTES π
for the deets on what these words even mean, go read attributes(7). no cap.
- Interface:
getopt_long_only() - Attribute: Thread safety
- Value:
MT-Unsafe race:getopt env
π ok so translate that: she is MT-Unsafe, there's literally a race on getopt, and she touches env. multiple threads + this function = messy. don't do it. not her fault, that's just the vibe π
β STANDARDS β
GNU. (of course. she's got that GNU energy, that's literally the whole point π§)
π SEE ALSO π
and that's the whole page, bestie, you ate it π β¨
this was brought to you by Linux man-pages 6.20, dated 2025-12-07 β mwah, love you, now go write some --long-options πππ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms