| substenv - Substitute environment variables in parameters and run the resulting command |
substenv - Substitute environment variables in parameters and run the resulting command
substenv [OPTIONS] [--] COMMAND [ARGS]
Replace all occurrances of $NAME in COMMAND and ARGS to the NAME environment
variable's value, whatever NAME would be, then run COMMAND ARGS.
Support ${NAME} curly bracket notation too.
Replace all occurrances of any $NAME (and ${NAME}) substring
(for details see LIMITATIONS).
This is the default behaviur, unless -e is given.
Replace the occurrances of NAME environment variable. May be specified more than once. If -a option is NOT given, ONLY these NAMEs are replaced.
Do not replace variables which are not defined (ie. not in the environment), but keep them as-is. By default they are replaced with the empty string.
Do not run COMMAND, just print what would be executed.
This function call, in C, runs substenv(1),
note, there is no dollar-interpolation in C.
execve("substenv", ["substenv", "ls", "$HOME/.config"])
Then substenv issues this system call:
execve("ls", ["ls", "/home/jdoe/.config"])
In "substitute all" mode (without -e flag) it replaces only names
with uppercase letters, digits, and underscore ([A-Z0-9_]+),
as env vars usually contain only these chars.
However it still replaces variables with lowercase letters in ${NAME} notation,
and specific variable(s) given in -e option(s).
Does not honour escaped dollar marks, ie. \$.
Does not support full shell-like variable interpolation. Use a real shell for it.
Sometimes you don't want a shell to be in the picture when composing commands, yet need to weave some environment variable into it.
envsubst(1) from gettext-base package
| substenv - Substitute environment variables in parameters and run the resulting command |