IFELSE(1)
π ifelse(1) β the general commands manual, bestie edition
okay so picture this: it's ifelse(1) from the General Commands Manual, and she is literally the two-branch queen of conditional execution. come sit, I'll explain everything π«Ά
β¨ NAME β¨
ifelse β do a conditional execution thing, but make it two branches, not one. main character energy fr fr π
πΈ SYNOPSIS πΈ
inside an execlineb(1) script, she looks like this:
ifelse [-X] [-n] { prog1... } { prog2... } prog3...
that's it. that's the whole vibe check. β¨
π¦ DESCRIPTION π¦
so ifelse reads prog1... inside a block (peep execline-block(7) if you don't know what a block is, iykyk). then she forks and executes it, and then she waits for it to finish. patient queen. π
now here's where it gets spicy πΆοΈ:
- if
prog1crashes,ifelseprints an error message and exits with 128 plus the number of the signal that killedprog1. yeah. rip. π - if
prog1exits with a return code equal to0,ifelsecallsexec(3)intoprog2. slay. β - else,
ifelsecallsexec(3)intoprog3. the other branch ate. π
and the lil equivalence, for the shell girlies:
βifelse prog1... "" prog2... "" prog3...β is roughly equivalent to βsh -c 'prog1... && exec prog2... || exec prog3...'β
roughly!! not exactly!! don't come for me π
π OPTIONS π
-nβ negate the test. flip it. inverse it. the vibe check, but backwards π-Xβ do not die ifprog1crashes; instead treat the crash as a non-zero (βfalseβ) exit. so dramatic deaths get politely recategorised as just... a no. no cap. π
π SEE ALSO π
the whole friend group, honestly:
background(1), backtick(1), execlineb(1), foreground(1), if(1), ifte(1), ifthenelse(1), pipeline(1), runblock(1), exec(3), execline-block(7)
also, this man page is ported from the authoritative documentation at: https://skarnet.org/software/execline/ifelse.html β go visit her, she's iconic πΈ
π AUTHORS π
- Laurent Bercot
- Alexis <flexibeast@gmail.com> (man page port)
okay that's the whole page, bestie β every flag, every branch, every signal number, preserved with love π
and for the cute sign-off: this one's the Debian build, dated February 14, 2021 β Valentine's Day, because she's that girl π see u in the next man page, mwah π§
π¦ 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