get_options(9)
π get_options(9) β like, the kernel's little number-parsing bestie
okay so this is a page from the Kernel API Manual (yes, that one, the big one) and honestly? she's lowkey iconic. get_options is the function that takes your messy little string and turns it into a nice tidy list of integers. no cap, it's giving "personal assistant for numbers." π
β¨ NAME β¨
get_options β Parse a string into a list of integers. that's it, that's the whole vibe. π«Ά
πΈ SYNOPSIS πΈ
char * get_options (const char *str , int nints , int *ints );
literally just three arguments, bestie, you got this π
π¦ ARGUMENTS π¦
strβ the string to be parsed. yes, that string, the one you've been staring at πnintsβ size of the integer array. she's the bouncer at the club, controls how many numbers get in πͺintsβ the integer array itself. must have room for at least one element β do not test her on this, okay? at least one, minimum, periodt π
π DESCRIPTION π
okay so here's what she actually does π₯
She parses a string that contains any of these three situations:
- a comma-separated list of integers,
- a hyphen-separated range of positive integers (emphasis on positive, bestie β that's the original's underscore energy, not mine β¨),
- or honestly a combination of both, because why not, main character energy π
The parse halts when the array is full, or when no more numbers can be retrieved from the string. She stops when the club's full or when there's nobody left in line. simple as. π
When nints is 0, the function just validates the given str and returns the amount of parseable integers as described below. so like, a vibe check, but for your string. no writing, just judging π§
The first element is filled by the number of collected integers in the range. the rest is what was parsed from the str. so element zero is the headcount π and everybody else is the actual crew π
Return value is the character in the string which caused the parse to end β typically a null terminator, if str is completely parseable. so if you got the '\0', congratulations, you ate and left no crumbs β
ngl, remembering the return is a character in the string and not a number is the whole game here. that's the tea π
π SEE ALSO π
- Kernel file
./lib/cmdline.c get_option(9)memparse(9)parse_option_str(9)
go read them, they're the friend group, iykyk π
and that's the page, bestie!! π¦ mwah π this one's from ./lib, dated October 2026, and yes she absolutely knew you'd be reading this in the future πβ¨ slay π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms