execline
Software
skarnet.org
The backtick program
backtick runs a program and stores its output in an
environment variable, then executes another program.
Interface
In an execlineb script:
backtick [ -i | -D default ] [ -n ] variable { prog1... } prog2...
- backtick reads prog1... in a
block and unquotes it.
- It runs prog1... as a child process and saves its
output in memory. This output must not contain a null character.
- backtick execs into the modified prog2..., with
variable added to the environment with prog1...'s
output as a value.
Options
- -i : insist. If prog1 crashes or exits non-zero,
backtick exits with an
approximation of the same exit code.
- -D default : default value. If
prog1 crashes or exits non-zero, default is used as
variable's value. If neither the -i nor the -D
option have been given, backtick execs into
prog2... no matter what prog1 does, with the null word as
variable's value if prog1 didn't write anything before
dying.
- -n : chomp an ending newline off prog1...'s
output.
Notes
- You can start prog2... with "import -u variable"
to perform variable substitution.