Question: I am not sure about this comparison i am doing:

```
   if [ "$exit_status" -eq 0 ];then
   #some statements
   fi

```

is this correct way of comparing numbers or quotes make the variable `exit_status` a string
to be compared with 0.I don't know if this could fail in some scenario.

Answer: 
`[ "$exit_status" -eq 0 ]` is correct if $exit\_status only contains digits, and you could just as well remove the quotes (as long as IFS doesn't contain digits).

If x is empty or unset, `[ "$x" -eq 6 ]` results in an error but `[[ "$x" -eq 6 ]]` doesn't:

```
$ x=; [ "$x" -eq 6 ]
-bash: [: : integer expression expected
$ unset x; [ "$x" -eq 6 ]
-bash: [: : integer expression expected
$ x=; [[ "$x" -eq 6 ]]
$ unset x; [[ "$x" -eq 6 ]]
$ 

```

Arithmetic operators strip whitespace:

```
$ [ '6 ' -eq $'\n\t6' ]; echo $?
0

```

Inside [[ the operands of arithmetic operators are arithmetic expressions, so for example `[[ 4 -eq 2+2 ]]` is true. Numbers that start with 0 are treated as octal numbers:

```
$ [[ 010 -eq 8 ]]; echo $?
0
$ [ 010 -eq 8 ]; echo $?
1

```

I often use = / == even for comparing integers. = and == are equivalent in bash inside both [[ and [. == and [[ are not defined by POSIX.

Word splitting and pathname expansion are not performed inside [[. `[[ $x = $y ]]` treats y as a pattern but `[[ $x = "$y" ]]` treats y literally:

```
$ x=44; y='4*'
$ [[ $x = $y ]]; echo $?
0
$ [[ $x = "$y" ]]; echo $?
1

```
Quoting numbers is of little use though. If the parameter value is a number then the quotes don't change anything and if it is not then the if is going to fail anyway. OK, not in every case:

```
exit_status="a = a -o 0"; [ "$exit_status" -eq 0 ] # returns false
exit_status="a = a -o 0"; [ $exit_status -eq 0 ] # returns true

```

This is due to `[` being a bash builtin but nonetheless a simple command whereas `[[` is a compound command that changes command line parsing.