get_option(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… get_option(9) β€” from the Kernel API Manual, bestie ✨

Okay so real talk: get_option is literally the girl who reads integers out of option strings. That's her whole job. She parses int values out of your command-line-ish strings and she does it flawlessly. Periodt. πŸŽ€


✨ SYNOPSIS ✨

int get_option (char **str , int *pint );

Like, that signature? Iconic. Chef's kiss. 🫢


🌸 ARGUMENTS 🌸

  • str β€” the option string, aka the text she's gonna dig through. The main character of the operation, honestly.
  • pint β€” the (optional output) integer value parsed from str. Optional!! We love a flexible queen. πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

So what she does is: read an int from an option string. And if there's a subsequent comma available? She accepts it too. Not greedy, just thorough. πŸ’…

When pint is NULL, that's your cue to use this function as a validator of the current option in the string. No output, just vibes β€” she'll tell you whether there's an int there or not. iykyk. πŸ‘‘

Also super important, no cap: a leading hyphen without an integer is no integer case. But β€” and this is the tea β€” we consume it anyway for the sake of simplification. She takes the hyphen on the way out. Rude? Maybe. Convenient? Absolutely. πŸ™ˆ


πŸ”₯ RETURN πŸ”₯

The vibe check results, in number form:

  1. 0 β€” no int in string. Sad. 😭 Empty-handed.
  2. 1 β€” int found, no subsequent comma. Clean, simple, slay. ✨
  3. 2 β€” int found including a subsequent comma. Overachiever behaviour. πŸ’€
  4. 3 β€” hyphen found to denote a range. Ooh, a range. Fancy. 🌈
⚠️ Heads up bestie: these are the only the return values the page gives you, so don't go assuming anything else, fr fr.

πŸ’œ SEE ALSO πŸ’œ

Go check out these icons, they're all in the kernel file ./lib/cmdline.c:


Okay bye bestie, go parse some ints πŸ’–βœ¨

Sign-off cuteness: this whole page lives in ./lib, dated October 2026, and it's get_option(9) β€” the Kernel API Manual's finest. πŸ§šβ€β™€οΈπŸ“

πŸ“¦ where this page comes from