p:: CLI

echo $? will return the exit status of last command.

echo $?
0
man bash
...

?      Expands to the status of the most recently executed foreground pipeline.

...