Copyright (C) 2000-2012 |
GNU Info (am-utils.info)Variable ExpansionVariable Expansion ------------------ To allow generic location specifications Amd does variable expansion on each location and also on some of the option strings. Any option or selector appearing in the form `$"var"' is replaced by the current value of that option or selector. For example, if the value of `${key}' was `bin', `${autodir}' was `/a' and `${fs}' was `${autodir}/local/${key}' then after expansion `${fs}' would have the value `/a/local/bin'. Any environment variable can be accessed in a similar way. Two pathname operators are available when expanding a variable. If the variable name begins with `/' then only the last component of the pathname is substituted. For example, if `${path}' was `/foo/bar' then `${/path}' would be expanded to `bar'. Similarly, if the variable name ends with `/' then all but the last component of the pathname is substituted. In the previous example, `${path/}' would be expanded to `/foo'. Two domain name operators are also provided. If the variable name begins with `.' then only the domain part of the name is substituted. For example, if `${rhost}' was `swan.doc.ic.ac.uk' then `${.rhost}' would be expanded to `doc.ic.ac.uk'. Similarly, if the variable name ends with `.' then only the host component is substituted. In the previous example, `${rhost.}' would be expanded to `swan'. Variable expansion is a two phase process. Before a location is parsed, all references to selectors, eg `${path}', are expanded. The location is then parsed, selections are evaluated and option assignments recorded. If there were no selections or they all succeeded the location is used and the values of the following options are expanded in the order given: SUBLINK, RFS, FS, OPTS, REMOPTS, MOUNT and UNMOUNT. Note that expansion of option values is done after "all" assignments have been completed and not in a purely left to right order as is done by the shell. This generally has the desired effect but care must be taken if one of the options references another, in which case the ordering can become significant. There are two special cases concerning variable expansion: 1. before a map is consulted, any selectors in the name received from the kernel are expanded. For example, if the request from the kernel was for `${arch}.bin' and the machine architecture was `vax', the value given to `${key}' would be `vax.bin'. 2. the value of `${rhost}' is expanded and normalized before the other options are expanded. The normalization process strips any local sub-domain components. For example, if `${domain}' was `Berkeley.EDU' and `${rhost}' was initially `snow.Berkeley.EDU', after the normalization it would simply be `snow'. Hostname normalization is currently done in a _case-dependent_ manner. |