IFELSE(1)

πŸ“¦ version 2.9.9.2, in nixpkgs unstable

πŸ’… 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 prog1 crashes, ifelse prints an error message and exits with 128 plus the number of the signal that killed prog1. yeah. rip. 😭
  • if prog1 exits with a return code equal to 0, ifelse calls exec(3) into prog2. slay. βœ…
  • else, ifelse calls exec(3) into prog3. 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 if prog1 crashes; 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