How can I do bash 'set -e', 'set -u' and 'set -x' in fish?

user1115652 picture user1115652 · Apr 18, 2014 · Viewed 7.5k times · Source

I suppose for set -e I could trap signals, but the others I have no clue.

Answer

ridiculous_fish picture ridiculous_fish · Apr 18, 2014

For completeness:

  • set -e: exits if a command fails
  • set -u: errors if an variable is referenced before being set
  • set -x: shows the commands that get run

Sorry, there's no equivalent of any of those options in fish! If you are interested in seeing them added, the issue tracking them is at https://github.com/fish-shell/fish-shell/issues/805

As you are surely discovering, fish is aimed more at interactive use than scripting. It's fine and common to use fish interactively, but write scripts using sh.