[ksh93-integration-discuss] about debug options in ksh

Roland Mainz roland.mainz at nrubsig.org
Fri May 4 16:07:32 PDT 2007


"paul.guo" wrote:
> I have two questions about ksh, and since I am not in the alias, please
> add my
> email address when replying.
> 
> 1. I am using ksh88, and found 'set -x' and 'set -v' do not work on
> sub-functions.
> Is ksh93 still like that ? Why don't allow these options in
> sub-functions?

AFAIK David Korn can answer that better than I do but AFAIK the reason
is that shell functions should be treated like normal commands, e.g.
either you debug the caller or the function (by adding $ set -o xtrace #
in the function) but not both at the same time.
Somewhere on my ToDo is DTrace support for ksh93 which should solve this
problem, alternatively there is "kshdbx" which solves this kind of
problem, too.

> 2. If you write scripts in shell languages, you must be very careful to
> prevent
> the typo. shell almost does not provide any options to prevent typo. Is
> is possible
> to add a set option to check if variable is undefined or null and send
> warning info to
> user.

You can do a $ set +o unset # (note the '+'), e.g.
-- snip --
$ set +o unset
$ echo ${foo} 
ksh93: foo: parameter not set
$ foo=1
$ echo ${foo}
1
$ unset foo
$ echo ${foo}
ksh93: foo: parameter not set
-- snip --

Does that help in your case ?

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)



More information about the ksh93-integration-discuss mailing list