How to get exit status of program in fish shell

Solution 1:

According to the official Fish documentation, you can use the $status variable:

How do I get the exit status of a command?

Use the $status variable. This replaces the $? variable used in some other shells.