ELSE(1)

🌸 ELSE(1) 🌸

ok bestie, so this is else from fish-shell β€” yes, that fish-shell πŸ’… β€” and honestly? she's the supporting character that makes the whole if situation work. let's get into it 🫢


✨ NAME ✨

else β€” run a command when a condition is not met πŸŽ€

✨ SYNOPSIS ✨

if CONDITION; COMMANDS_TRUE ...; [else; COMMANDS_FALSE ...;] end

✨ DESCRIPTION ✨

okay so here's the tea β˜• β€” if will execute the command CONDITION. and if that condition's exit status is 0? slay, the commands COMMANDS_TRUE will execute. main character behavior tbh πŸ‘‘

but if the exit status is not 0 and else is given, then COMMANDS_FALSE gets executed instead. it's giving "you get a turn too" energy, no cap πŸ’–

lowkey the whole point: else is the fallback. condition flopped? else catches you. 🧚

✨ EXAMPLE ✨

the following code tests whether a file foo.txt exists as a regular file:

if test -f foo.txt
    echo foo.txt exists
else
    echo foo.txt does not exist
end

like literally, that's it. test -f checks it's a regular file, and else handles the "nope, not there" timeline πŸ˜­πŸ¦‹

fish-shell developers πŸŸπŸ’œ


k bye bestie, go write some conditionals that actually work ✨ version 4.9, dated Sep 08, 2026, brought to you by the fish-shell developers β€” mwah πŸŽ€πŸ’–πŸŒ·

πŸ“¦ where this page comes from
  • arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms