execline
Software
www.skarnet.org
The forbacktickx program
forbacktickx runs a program and uses its output as loop elements to
run another program.
Interface
In an execlineb script:
forbacktickx [ -E | -e ] [ -p | -x breakcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] variable { gen... } loop...
- forbacktickx reads a
block,
gen..., and unquotes it.
- It runs gen... as a child process. gen's
output must not contain a null character.
- It reads gen's output as it needs,
splitting it automatically.
- For every argument x in the split output:
- forbacktickx performs
variable substitution on
loop..., with variable as key and x
as value.
- It runs loop... as a child process.
- forbacktickx then exits 0.
Options
- -p : parallel mode. Do not wait for a loop...
instance to finish before spawning the next one. forbacktickx will
still wait for all instances of loop to terminate before
exiting, though.
- -0 : accept null characters from gen's output,
using them as delimitors. If this option and a -d option are
used simultaneously, the rightmost one wins.
- -x breakcode : If at some point loop...
exits with the breakcode exit code, do not keep looping, but
exit immediately with the same exit code. This doesn't apply if the -p option
has been given.
- -E : forbacktickx performs the substitution for
variable itself. This is the current default, but it will change at some
point.
- -e : forbacktickx does not perform the substition for
variable; instead, it adds variable to loop's
environment, and loop should use the import
command to actually substitute variable. This will become the
default in the future.
- Other options are used to control
the substitution mechanism for every x. Of course, you can't
split x.
Notes
- forbacktickx -E var { gen... } loop... is exactly equivalent to
forbacktickx -e var { gen... } import var unexport var loop....
It is actually implemented like this.