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

4.2.2 Transformations

Special actions that allow to rewrite command line are called transformations. GNU Rush supports five kinds of transformations: ‘set’, ‘transform’, ‘delete’, ‘map’. All of them operate on command line split into words. Additionally, ‘set’ and ‘transform’ can operate on the entire command line.

Rush performs word splitting using the same rules as sh. Transformation actions refer to words by their index. Three kinds of indexes are supported. First of all, a word may be referred to by its ordinal number in the command line. The command name itself has index ‘0’. For example, given the command line:

/bin/scp -t /upload

one gets:

IndexValue
0/bin/scp
1-t
2/upload

Negative indexes can also be used. They refer to words in the backward order, as illustrated in the following table:

IndexValue
-1/upload
-2-t
-3/bin/scp

Finally, the last word may be referred to as ‘$’, and the command name itself as ‘^’. There is a subtle difference between ‘0’ and ‘^’. The notation ‘^’ refers to the name of the program that rush will execute at the end of the matching rule, whereas the notation ‘0’ refers to the 0th argument that will be passed to that program (‘argv[0]’). Most of the time the two values coincide. Unless the rule modifies ‘^’, ‘0’th word will be used as the program name. There exist some cases when you need to explicitly set ‘^’. See Interactive, for a possible use of this feature.

Some of the transformations implement patterns. A pattern is a string which may contain meta-variables. Before using, these meta-variables are expanded using the following rules:

Meta-variableExpansion
${user}User name
${group}Name of the user’s principal group
${uid}UID
${gid}GID
${home}User’s home directory
${gecos}User’s GECOS field
${program}Program name (‘^’)
${command}Full command line
$0 to $9Corresponding word from the command line
${N}Nth word (see above for the allowed values of N)

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