[comp.unix.questions] Debugging ksh scripts

ijk@cbnewsh.ATT.COM (ihor.j.kinal) (07/01/89)

I'm trying to debug an error from a chain of about 6 shell scripts
[one calls the next, and each call a setup script].  The error
only occurs when a certain execution path is chosen, but unfortunately,
I can't discover why that does make a difference.

I believe the error is coming from the setup script, but when I
I turn on execution trace in that script, the error seems to go away.

The error is :
[82]:	test - argument expected

I've looked at lines 82 in my scripts, and I can't spot any test 
statement or of course, the alternative [ ] .

Questions: 

1)  is the line number indicative of the line number - or can comments or
something else change that line number????.


2). is there any way to force the script to identify itself by name,
and/or context when it encounters an error?

3).  Can something else produce this error message, except what I expect??
{ i.e., test or [ ] }?

I'm using ksh 86,[ on a HP 850]
 although a version of the latest 88 might be available.

Any thoughts are appreciated - this has been driving me bonkers!!!
		[well, at least it's an excuse ]

Thanks,

Ihor Kinal
[att!violin!ijk]
cbnewsh!ijk

davidsen@crdgw1.crd.ge.com (William E. Davidsen Jr) (07/04/89)

Since you ask for thoughts, look for a function doing the dirty work.
See if you have a test as the 86th line in a function definition...
-- 
	- bill davidsen (davidsen@crdgw1.uucp)
	GE Corp. R&D Center; Box 8, KW-C206; Schenectady NY 12345

franl@damogran.prime.com (07/09/89)

Look for something like this:

  if [ $VAR ]
  then
    ...
  fi

which is testing (poorly) whether the value of the variable VAR is not
the null string.  When VAR is not set, it is interpreted as

  if [ ]		<=== here, "[" (aka "test") has no arguments!
  then
    ...
  fi
--
Fran Litterio
Internet: franl@damogran.prime.com
Usenet:   {uunet | csnet-relay}!primerd!damogran!franl
Voice:    USA-508-879-2960 x4251