# Debugging a script with noexec

**URL:** <https://community.unix.com/t/debugging-a-script-with-noexec/302729>\
**Category:** Shell Programming and Scripting\
**Created:** [January 13, 2012, 1:55pm UTC](https://community.unix.com/t/debugging-a-script-with-noexec/302729 "2012-01-13T13:55:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fgoyti](https://community.unix.com/letter_avatar/fgoyti/32/6_449c533f586939b6e5f246632a46421f.png) [@fgoyti](https://community.unix.com/u/fgoyti)\
**Post date:** [January 13, 2012, 1:55pm UTC](https://community.unix.com/t/debugging-a-script-with-noexec/302729/1 "2012-01-13T13:55:11Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [January 13, 2012, 2:03pm UTC](https://community.unix.com/t/debugging-a-script-with-noexec/302729/2 "2012-01-13T14:03:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fgoyti](https://community.unix.com/letter_avatar/fgoyti/32/6_449c533f586939b6e5f246632a46421f.png) [@fgoyti](https://community.unix.com/u/fgoyti)\
**Post date:** [January 13, 2012, 2:08pm UTC](https://community.unix.com/t/debugging-a-script-with-noexec/302729/3 "2012-01-13T14:08:00Z")

</div>

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

```nohighlight
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.
