TRYEXEC(1)

NAME
tryexec - execute into a command line, with a fallback

SYNOPSIS
In an execlineb(1) script:

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

DESCRIPTION
tryexec reads prog1... in a block ( cf. execline-block(7)). It then executes into it, completely forgetting prog2....

If for some reason the execve(2) fails - for instance, a non-executable prog1 - then tryexec executes into prog2... instead.

‘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.

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(1) program.

SEE ALSO
emptyenv(1), envfile(1), exec(1), execline-cd(1), execline-umask(1), execlineb(1), exit(1), export(1), fdblock(1), fdclose(1), fdmove(1), fdreserve(1), fdswap(1), getcwd(1), getpid(1), heredoc(1), piperw(1), posix-cd(1), posix-umask(1), redirfd(1), trap(1), unexport(1), wait(1), withstdinas(1), execve(2), execline-block(7)

This man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/tryexec.html

AUTHORS
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)