[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.2.5 Positional Parameters

Normally radtest stops parsing its command line when it encounters either first non-optional argument (i.e. the one not starting with dash), or an argument consisting of two dashes. The rest of the command line starting from the first non-optional argument forms positional parameters. These parameters are said to form the top-level environment.

Similarly, when invoking a user-defined function (see section Function Definitions), arguments passed to it are said to form the current environment of the function. These arguments are positional parameters for this function.

Positional parameters are assigned numbers starting from 1. To access (dereference) a positional parameter, the syntax $n is used, where n is the number of the parameter. Alternative forms, such as ${n} or ${n:-text}, can also be used. These work exactly as described in Dereferencing Variables).

The number of positional parameters can be accessed using a special notation $#.

Several things need to be mentioned:

For example, suppose you run:

radtest -f script.rad name foo=bar 5

Then, the top-level environment of program ‘script.rad’ consists of the following variables:

$0 ⇒ script.rad
$1 ⇒ name
$2 ⇒ 5

This document was generated by Sergey Poznyakoff on December, 6 2008 using texi2html 1.78.