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:elseis the fallback. condition flopped?elsecatches 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 ππ¦
β¨ Copyright β¨
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