execline: the loopwhilex command
Keywords: execline command loopwhilex

execline
Software
skarnet.org

# The `loopwhilex` program

`loopwhilex` performs a conditional loop.

## Interface

         loopwhilex [ -n ] [ -o okcodes | -x breakcodes ] prog...

- `loopwhilex` runs prog... as a child process and waits for it to complete.
- As long as prog exits zero, `loopwhile` runs it again.
- `loopwhilex` then exits with an approximation of the last prog invocation's exit code.

## Options

- `-o` okcodes : okcodes must be a comma-separated list of exit codes. `loopwhilex` will keep looping as long as prog exits with one of the codes in okcodes.
- `-x` breakcodes : like the previous option, but with inverted meaning - the listed exit codes are codes that will break the loop and exit, and the unlisted exit codes will keep the loop running.
- `-n` : negate the test. This option is now redundant, and may disappear soon.

## Notes

- `loopwhilex prog...` is equivalent to `loopwhilex -n -x 0 prog...` and `loopwhilex -o 0 prog...`
- Be careful: execline maintains no state, in particular it uses no real variables, and environment will be of no use here since every instance of prog... runs as a separate child process. To avoid being stuck in an infinite loop, prog... should modify some external state - for instance, the filesystem.