ELGETPOSITIONALS(1)

πŸ“¦ version 2.9.9.2, in nixpkgs unstable

πŸ’… 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 the 0 environment variable holds
  • key 1, value: whatever the 1 environment 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 from 1 to n. this value gets split (cf. execline-transform(7)) into n words.
⚠️ and if a variable between 0 and n doesn't exist? yeah. elgetpositionals exits 100. 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 least sharp+1 positional parameters, from 0 to 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 -P switch? that's equivalent to having -P 0. iykyk ✨

πŸ¦‹ SEE ALSO πŸ¦‹

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