AND(1)
AND(1) from fish-shell β conditionally execute a command π¦
β¨ NAME β¨
and β conditionally execute a command. That's the whole vibe: it's the command that says βrun the next thing only if the last thing slayed.β π
β¨ SYNOPSIS β¨
PREVIOUS; and COMMAND
Periodt. That semicolon is doing main character work.
β¨ DESCRIPTION β¨
Okay so bestie, and is used to execute a command if the previous command was successful (returned a status of 0). No cap β that's the gatekeeping moment right there.
and statements may be used as part of the condition in a while block or an if block. It's giving conditional energy, and honestly? Obsessed.
Now the lowkey important part: and does not change the current exit status itself, but the command it runs most likely will. The exit status of the last foreground command to exit can always be accessed using the $status variable. Keep that in your notes, iykyk. π«Ά
Also, the -h or --help option displays help about using this command. Helpful king behavior fr fr.
β¨ EXAMPLE β¨
The following code runs the make command to build a program. If the build succeeds, make's exit status is 0, and the program is installed. If either step fails, the exit status is 1, and make clean is run, which removes the files created by the build process.
make; and make install; or make clean
Vibe check: build it, install it if it ate, clean up if it flopped. πβ¨
β¨ SEE ALSO β¨
orβ commandnotβ command
β¨ Copyright β¨
fish-shell developers
xoxo, AND(1) from fish-shell, version 4.9, dated Sep 08, 2026 β 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