execline: the tryexec command
Keywords: execline command tryexec

execline
Software
skarnet.org

# The `tryexec` program

`tryexec` executes into a command line, with a fallback.

## Interface

In an execlineb script:

         tryexec [ -n ] [ -c ] [ -l ] [ -a argv0 ] { prog1... } prog2...

- `tryexec` reads prog1... in a block. It then executes into it, completely forgetting prog2...
- If for some reason the `execve()` fails - for instance, a non-executable prog1 - then `tryexec` executes into prog2... instead.

## Options

- `-n` : reverse prog1... and prog2...'s role. The latter becomes the main execution path and the former becomes the fallback.

The `-c`, `-l` and `-a` options have the same semantics as with the exec program.

## Notes

- `tryexec prog1... "" prog2...` would be equivalent to `sh -c 'exec prog1... || exec prog2...'`, if such a shell construct existed. Unfortunately, the shell language does not offer that functionality.