Question on NULL and zero value of variable

Hi all, I have a stupid question on NULL and zero(0).

In a script I've been working with, one of the lines is:

if [ $intchk1 == 1 ] && [ $Current_csm2 != 0 ] 
then

The problem I seem to have is when $Current_csm2 is null, this if block is not triggered, and I don't get why because I was under the impression that NULL!=0

Can anyone give me some pointers?

Thanks.

 
man test

Are you suggesting I use the following?

if [ $intchk1 == 1 -a $Current_csm2 != 0 ] 
then

Can you give me a pointer why my code will not work? I don't mind changing code, but I'd prefer to understand why what I had to begin with did not work?

thanks.

 
test -z $Current_csm2

I may not have been clear, I'll try again.

I want this if block to trigger if $intcheck == 1 and $Current_csm2 is a value other then 0, so it might be NULL or it may be 3 or it may be "foo", any of these would cause the script to exit with a specific exit code.

if $intcheck == 1 and $Current_csm2==0, I want the if block to be bypassed and the rest of the script to run.

 
if [ $intchk1 == 1 -a ! -z $Current_csm2 ] 
then

Thanks anyway, but that did not work, I think I'll have to do some serious rewriting of the script.

---------- Post updated at 02:14 PM ---------- Previous update was at 01:59 PM ----------

Ok, it does work when the variable is quoted:

if [ $intchk1 == 1 -a ! -z "$Current_csm2" ] 
then

Thanks for the pointer.

Yes the variable must be quoted so the test "sees" the null.