execline
Software
skarnet.org
The forstdin program
forstdin uses its input as loop elements to
run another program.
Interface
In an execlineb script:
forstdin [ -p | -o okcodes | -x breakcodes ] [ -E firsteofcode ] [ -e eofcode ] [ -n ] [ -C | -c ] [ -0 | -d delim ] variable loop...
- forstdin reads its standard input as it becomes available,
splitting it on every line automatically.
- For every argument x in the split output,
forstdin runs loop... as a child process, with
variable=x added to its environment.
- forstdin then exits 0 if it has read something on stdin,
and 1 if it hasn't read anything.
Options
- -p : parallel mode. Do not wait for a loop...
instance to finish before spawning the next one. forstdin will
still wait for all instances of loop to terminate before
exiting, though.
- -0 : accept null characters on its stdin,
using them as delimiters. If this option and a -d option are
used simultaneously, the rightmost one wins.
- -o okcodes : okcodes must
be a comma-separated list of exit codes. If the -p flag
hasn't been given and loop exits with one of the codes in
okcodes,
forstdin will run the following instances of the loop, but if the exit code is
not listed in okcodes, forstdin will exit immediately with an
approximation of the same exit code.
- -x breakcodes : like the previous
option, but with inverted meaning - the listed exit codes are codes
that will make forstdin break the loop and exit, and the unlisted exit
codes will make it keep looping.
- -E firsteofcode : if forstdin encounters
EOF on its first attempt to read data, exit firsteofcode. Default is 1.
- -e eofcode : if forstdin has already
read data, and encounters EOF, exit eofcode. Default is 0.
- Other options are used to control
the substitution mechanism for every x. Of course, you can't
split x. The default delimiter for forstdin is a
newline; you need a -d option to split x around
other values.
Notes
- You can start loop... with "importas -u variable variable"
to perform variable substitution.