execline: the ifthenelse command
Keywords: execline command ifthenelse

execline
Software
skarnet.org

# The `ifthenelse` program

`ifthenelse` performs a conditional alternative.

## Interface

In an execlineb script:

         ifthenelse [ -X ] [ -s ] { progif... } { progthen... } { progelse... } prog...

- `ifthenelse` reads progif..., progthen... and progelse... in 3 consecutive blocks.
- `ifthenelse` runs progif... as a child process and waits for it to complete.
- If progif... crashes (i.e. is killed by a signal), `ifthenelse` prints an error message, then exits 128 plus the number of the signal that killed progif.
- If progif... exits zero, `ifthenelse` runs progthen... as a child process, else it runs progelse....
- `ifthenelse` waits for its child to complete and puts the exit status in the `?` environment variable. It then execs into prog....

## Options

- `-X` : if progif crashes, do not exit; proceed as if it had returned false.
- `-s` : magic scoping hack. This option does powerful but ugly things, and is left undocumented on purpose.