The withstdinas program
withstdinas reads the entirety of its standard input in an environment variable, and runs another program with that additional environment variable.
Interface
In an execlineb script:
withstdinas [ -i | -I | -D default ] [ -N | -n ] [ -E | -e ] variable prog...
- withstdinas reads its stdin until EOF.
- It then execs into prog..., with variable added to the environment; the value of variable is what was read on stdin.
Options
- -N : do not chomp an ending newline off stdin.
- -n : chomp an ending newline off stdin. This is the default.
- -e : no autoimport. This is the default.
- -E : autoimport. Instead of exec'ing into prog..., exec into importas -ui variable variable prog.... This substitutes variable into the command line instead of putting it into the environment.
The other options tell withstdinas what to do if its input is not suitable as the contents of an environment variable, i.e. it contains a null character:
- -i : withstdinas exits 1.
- -I : variable is removed from the environment, and execution proceeds.
- -D default : the value of variable is set to default, and execution proceeds.
- neither of those options: the value of variable is set to whatever the start of the input is, up to the first null character; and execution proceeds.
Notes
- You can start prog... with "importas -u variable variable" to perform variable substitution.
