Debugging a script with noexec

Newbie question. I cannot get "set -n" or "set -noexec on" to work on Linux or AIX! According to the man page and what I read online, it should inform me of syntax errors without executing commands in your script.

So, can someone PLEASE explain why this does not work?

======================================
# WHAT I SHOULD SEE

rochatk:/tmp # cat t1
#set -n

echo test
ech test1

rochatk:/tmp # ./t1
test
./t1: line 4: ech: command not found

# REMOVE COMMENT FROM SET COMMAND

rochatk:/tmp # vi t1
rochatk:/tmp # cat t1
set -n

echo test
ech test1

rochatk:/tmp # ./t1
rochatk:/tmp #

======================================

Why don't I see the error after "set -n" is enabled?
Thank you for your help!

There's nothing wrong with the syntax, though. If 'ech' actually existed on your system, it would be run.

So syntax checking alone won't catch this error.

I see, you are correct. I tried a bad syntax example and it worked as expected

if [ 3 -eq 4 ];
  echo wrong
fi

DOES yield a syntax error.

So, this isn't as useful as I hoped if it doesn't catch ALL the errors, but thank you for your help in understanding why.