TRYEXEC(1)
π tryexec β execute into a command line, with a fallback β¨
hii bestie π«Ά this is tryexec(1) from the General Commands Manual, and it is genuinely such a useful little exec gremlin. no cap, the whole point is: try one command line, and if that fails, fall back to another one. π
πΈ NAME πΈ
tryexec β execute into a command line, with a fallback. that's the whole vibe. π
π¦ SYNOPSIS π¦
inside an execlineb(1) script, bestie, it looks like this:
tryexec [-n] [-c] [-l] [-a argv0] { prog1... } prog2...
β¨ DESCRIPTION β¨
okay so tryexec reads prog1... in a block (cf. execline-block(7)). then it executes into that block, and it completely forgets prog2.... like, gone. not invited to the exec party anymore. π
but if for some reason the execve(2) fails β for instance, because prog1 is non-executable β then tryexec executes into prog2... instead. fallback era. π
for the record, 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. and that's the lore. π
π OPTIONS π
the -c, -l and -a options have the same semantics as with the exec(1) program β go check that icon if you need the details, bestie. π
-nβ reverseprog1...andprog2...'s role. the latter becomes the main execution path, and the former becomes the fallback. plot twist. π₯-cβ same semantics as with theexec(1)program.-lβ same semantics as with theexec(1)program.-a argv0β same semantics as with theexec(1)program.
π SEE ALSO π
go stalk these icons: 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)
Debian, February 14, 2021 β mwah, bye bestie! π
π¦ where this page comes from
- nixpkgs unstable: execline 2.9.9.2
- nixpkgs unstable: execline-man-pages 2.9.9.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms