execline
Software
skarnet.org
The backtick program
backtick runs a program and uses its output as the argument of
another program.
Interface
In an execlineb script:
backtick [ -E | -e ] [ -i ] [ -n ] [ -s ] [ -C | -c ] [ -d delim ] 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 performs
variable substitution on
prog2..., with variable as key and that output as value.
backtick's options are used to control
the substitution mechanism.
- backtick execs into the modified prog2....
Options
- -i : insist. If prog1 exits non-zero,
backtick exits with the same exit code (or 111 if prog1
crashed for some reason). Without this option, 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.
- -E : backtick performs the substitution for variable
itself. This is the current default, but it will change at some
point.
- -e : backtick does not perform the substition for
variable; instead, it adds variable to prog2's
environment, and prog2 should use the import
command to actually substitute variable. This will become the
default in the future.
- Other options control
variable substitution.
Notes
- backtick -E var { prog1... } prog2... is exactly equivalent to
backtick -e var { prog1... } import var unexport var prog2....
It is actually implemented like this.