ELGETPOSITIONALS(1)
π ELGETPOSITIONALS(1) β the execline positional-parameter glow-up π
okay so bestie, quick vibe check: this is a General Commands Manual page for elgetpositionals, and it's genuinely iconic. it does exactly what the name says β it substitutes the positional parameters of an execline script. no cap. let's get into it π«Ά
β¨ SYNOPSIS β¨
elgetpositionals [-P sharp] prog...
that's the whole shape of it. prog... is your program and its args, and -P sharp is the optional little sprinkle on top π
πΈ DESCRIPTION πΈ
so. elgetpositionals reads the number n of βpositional parametersβ out of the # environment variable. that's the whole source of truth. and if that variable isn't set, or it doesn't contain a valid n? girl, it's over β elgetpositionals exits 100. π
then it performs some substitutions (cf. execline-substitute(7)) in parallel on prog.... and here's the tea, substitution by substitution:
- key
#, value: n - key
0, value: whatever the0environment variable holds - key
1, value: whatever the1environment variable holds - ... and so on and so on until n (or until sharp, if sharp is greater than n). and listen β those values are never transformed. periodt. π
- key
@, value: all the values of the variables from1to n. this value gets split (cf.execline-transform(7)) into n words.
β οΈ and if a variable between0and n doesn't exist? yeah.elgetpositionalsexits100. that's the rule, i don't make 'em.
a typical argument-taking execline script will often begin this way, and honestly it's giving main character energy:
#!/command/execlineb
elgetopt optstring
elgetpositionals
prog...
if you're performing other substitutions that don't depend on the positional parameters, lowkey think about replacing the elgetpositionals call with a multisubstitute(1) call containing the elgetpositionals directive. π
and if you're going to use the shift(1) command β okay this is important β it's best to use importas(1) to substitute the first positional parameters, then use shift(1), then elgetpositionals. that way $@ will correctly be replaced by the remaining arguments. more generally? you should try to use elgetpositionals as late as possible. fr fr. π
also, use execlineb(1)'s -S switch instead of elgetpositionals whenever you can. it's more efficient. not me telling you the faster way, but like, i am π
π OPTIONS π
-P sharpβ substitute at leastsharp+1positional parameters, from0to max(n, sharp). and if n < sharp, the positional parameters between n+1 and sharp get replaced with the empty string. oh and not having the-Pswitch? that's equivalent to having-P 0. iykyk β¨
π¦ SEE ALSO π¦
define(1)elglob(1)execlineb(1)importas(1)multidefine(1)multisubstitute(1)shift(1)execline-substitute(7)execline-transform(7)
this man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/elgetpositionals.html β the source material, the blueprint, the origin story π§
π AUTHORS π
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port)
okay that's the whole page, you ate that. go substitute some positional parameters bestie πΈπβ¨
Debian Β· February 14, 2021 Β· valentine's day release, how romantic is that πππ
π¦ where this page comes from
- nixpkgs unstable: execline 2.9.9.2
- nixpkgs unstable: execline-man-pages 2.9.9.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms