Question: I am looking for a test that would return `true` if the environment variable is defined and has a value different than `0`, `false` or `NULL`.

```
ENABLE_SOMETHING=1
# or ENABLE_SOMETHING=true

if ... do ...

```

Note: under no circumstance the bash should complain about the variable not being defined or having a weird value, anything else than 0, empty, false, or not defined would be considered true.

Answer: 
Such a test does not exist as it might in a high-level language such as Java or C#, but it is relatively easy to construct.

Three comments on your question as asked: 

1: You do not work with literal "true"/"false" values in bash; all commands and conditional constructs yield an **exit status**, or *logical result*, which is either 0 (true) or non-0 (false).  

Work with this, don't try to re-invent the wheel.

2: Try not to use upper-case parameter names unless they are environment variables; this is a simple convention that helps keep your code clean.

3: What, exactly, do you mean by "NULL"? The literal string **NULL**, an empty value, or something else?  

The latter two concepts don't exist in bash; a *NULL* variable would be unset, which you're already checking for.

The most effective solution would be a function that accepts a variable (or parameter, as bash calls them), and checks for those conditions, then sets the exit status based on that, effectively condensing multiple truth values to a literal 0 or 1.

For example:

`is_true() { if [[ "$1" = 0 ]]; then false; elif [[ -z "$1" ]]; then false; elif [[ "$1" =~ [Ff][Aa][Ll][Ss][Ee] ]]; then false; fi; }`

* `is_true "1"` yields 0, which is true
* `is_true "false"` yields 1, which is false
* `a=10; is_true "$a"` yields 0
* `grep -q something somefile` yields 0 if `something` appears at least once in `somefile`.

NOTE that the latter example clearly shows that you don't NEED such a construct; everything that happens in bash ***already*** works with these basic 0/1 truth values.

But I'll grant that you might have to convert input from some gnarly external program :)
You could do all three checks with regular expression matching (undefined parameters resolve to the empty string):

```
is_true() (
  shopt -s nocasematch
  [[ ! $1 =~ ^(false|0|)$ ]]
)

```