ELGETPOSITIONALS(1)

NAME
elgetpositionals - substitute the positional parameters of an execline script

SYNOPSIS
elgetpositionals [-P sharp] prog...

DESCRIPTION
elgetpositionals reads the number n of “positional parameters” in the # environment variable. If that variable is not set or does not contain a valid n, elgetpositionals exits 100.

elgetpositionals performs some substitutions ( cf. execline-substitute(7)) in parallel on prog...:

•   key: ‘#’, value: n

•   key: ‘0’, value: the value of the 0 environment variable

•   key: ‘1’, value: the value of the 1 environment variable

•   ... and so on until n ( or sharp if it is greater than n). Those values are never transformed.

•   key: ‘@’, value: all values of the variables from ‘1’ to n. This value is split ( cf. execline-transform(7)) into n words.

If a variable between ‘0’ and n does not exist, elgetpositionals exits 100.

A typical argument-taking execline script will often begin this way:

    #!/command/execlineb
    elgetopt optstring
    elgetpositionals
    prog...

If you are performing other substitutions that do not depend on the positional parameters, think about replacing the elgetpositionals call with a multisubstitute(1) call containing the ‘elgetpositionals’ directive.

If you are going to use the shift(1) command, it is 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.

Use execlineb(1)' s -S switch instead of elgetpositionals whenever you can. It is more efficient.

OPTIONS

-P sharp
    Substitute at least sharp +1 positional parameters, from 0 to max(n, sharp). If n < sharp, positional parameters between n +1 and sharp are replaced with the empty string. Not having the -P switch is equivalent to having ‘-P 0’.

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

AUTHORS
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)