How can I know if the set -e option is enabled or not?

Solution 1:

Look at the value of $-, if it contains an 'e', then the '-e' option is set. This variable contains a list of all set options. This is described in the bash man page.

Solution 2:

I like both answers. Ansgar's suggestion works well with bash, Trevor's is good if grep is in the PATH. If you want to be independent of shell (bash/sh) and PATH you could use

[ "${-#*e}" != "$-" ]