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 β€” command
  • not β€” command

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