GNU Rush |
|
Restricted User Shell |
Sergey Poznyakoff |
map
statementThe ‘map’ statement uses file lookup to find a new value for the variable name (or, in its second form, for the positional variable ‘$n’).
Arguments are:
Name of the map file. It must begin with ‘/’ or ‘~/’. Before using, the file permissions and ownership are checked using the procedure described in security checks.
A string containing allowed field delimiters.
The value of the lookup key. Before using, it undergoes backslash interpretation and variable expansion.
Number of the key field in file. Fields are numbered starting from 1.
Number of the value field.
If supplied, this value is used as a replacement value, when the key was not found in file.
The map file consists of records, separated by newline characters (in other words, a record occupies one line). Each record consists of fields, separated by delimiters listed in delim argument. If delim contains a space character, then fields may be delimited by any amount of whitespace characters (spaces and/or tabulations). Otherwise, exactly one delimiter delimits fields.
Fields are numbered starting from 1.
The map
action works as follows:
For example, suppose that the file /etc/passwd.rush has the same syntax as the system passwd file (see Password File in passwd(5) man page). Then, the following statement will replace ‘$0’ with the value of ‘shell’ field, using the current user name as a key:
map [0] /etc/passwd.rush : ${user} 1 7
See also Interactive, for another example of using this statement.
This document was generated on January 2, 2022 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.