Prefer 'if ! [[ $x = $y ]]; then error "x != y"; fi' to 'if [[ $x != $y ]]; then error "x != y"; fi'. Since the second form gives a false pass when x or y is not initialized correctly.
There are several reasons why it is helpful to do string comparisons using a prefix and quoting them. The reasons are numerous and do not go away for different flavors of "test".
2 Comments
John Hammond
Prefer 'if ! [[ $x = $y ]]; then error "x != y"; fi' to 'if [[ $x != $y ]]; then error "x != y"; fi'. Since the second form gives a false pass when x or y is not initialized correctly.
Bruce Korb
test "X$x" = "X$y" || die 'x and y differ'
There are several reasons why it is helpful to do string comparisons using a prefix and quoting them. The reasons are numerous and do not go away for different flavors of "test".