I am looking for an elegant way of testing the result of the last executed command and branch depending on the result. The construct I want to build upon is the following:

```
if /bin/true ; then
  do_stuff
fi

```

This works great when we want to test for success. But how can I test for failure? When I'm doing intensive error checking, what I want to do is the equivalent of this:

```
if ! /bin/true ; then
  do_error_handling
fi

```

The best solution I have found so far is to define two simple macros in my scripts:

```
onSuccess() { [[ $? -eq 0 ]]; }
onError () { [[ $? -ne 0 ]]; }

```

Then I can do stuff like this:

```
some_command
if onError ; then
  # error handling block
fi

```

But I would prefer a lot more using something built in in bash so I don't have to replicate these macros in every script I write. 

This "problem" of mine is a lot about the style of code I want to write. I want to escape the repetitive `if [ $? -ne 0 ]` ugliness.