GNU Rush – a restricted user shell (split by node):   Section:   Chapter:FastBack: Configuration File   Up: Request   FastForward: Default Configuration   Contents: Table of ContentsIndex: Concept Index

4.4.1.1 Positional variables

Rush performs word splitting using the same rules as sh. Statements in the configuration file refer to command line arguments (words) by their index, using positional variables. A positional variable can have the following forms:

 $n
 ${n}

where n is the variable index. The form with curly braces must be used if n is negative (see below) or greater than 9.

Arguments are numbered from ‘0’. The name of the command is argument ‘$0’. Consider, for example, the following command line:

/bin/scp -t /upload

Word splitting phase results in three positional variables being defined:

VariableValue
$0/bin/scp
$1-t
$2/upload

These values can also be referred to using negative indexes. They refer to words in the reverse order, as illustrated in the following table (notice the use of curly braces):

VariableValue
${-3}/bin/scp
${-2}-t
${-1}/upload

Notice also, that negative indexes are 1-based.

One final note about the ‘$0’ variable. Immediately after word splitting it refers to both the executable program name and the 0th argument that will be passed to that program (argv[0]). Most of the time the two values coincide. However, the rule can modify either value, so that they become different. Whether modified or not, the actual name of the program to be run is kept in the request variable ‘$program’ (see the following section).

GNU Rush – a restricted user shell (split by node):   Section:   Chapter:FastBack: Configuration File   Up: Request   FastForward: Default Configuration   Contents: Table of ContentsIndex: Concept Index