The importas program
importas replaces a literal with the value of an environment variable, then executes another program.
Interface
importas [ -i | -D default ] [ -u ] [ -s ] [ -C | -c ] [ -N | -n ] [ -d delim ] variable envvar prog...
importas -S [ -i | -D default ] [ -u ] [ -s ] [ -C | -c ] [ -N | -n ] [ -d delim ] envvar prog...
- importas fetches the value of envvar in the environment. If neither the -D nor the -i option is given, and envvar is undefined, no word is returned (that is different from the empty word).
- importas then performs variable substitution on prog..., with variable as key and that string as value.
- importas then execs into the modified prog....
Options
- -D default : If this option is given and envvar is undefined, substitute default for the value of variable instead of no word. For instance, to substitute the empty word, use -D "".
- -i : Insist. If envvar is undefined, importas will not do anything; instead, it will exit 100 with an error message. This has precedence over any -D option.
- -u : Unexport. envvar will be removed from the environment after the substitution. importas -u variable envvar is equivalent to importas variable envvar unexport envvar.
- -S : import with same name. This option allows
variable to be omitted; it will be the same as envvar.
In other words,
importas -S varis the same asimportas var var. - Other options are used to control the substitution mechanism.
Notes
- When envvar is undefined, and the -D option is not given, any variable substitution with variable as the key will return no word; that is true even when the ${variable} form to be substituted happens in the middle of a word (with a prefix and/or a postfix), which means the whole word will be deleted. If this is not the behaviour you want, use the -D option.
