-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I have tried to reduce the issue to a small (if not quite minimal) example. consider this setup:
- a script named
dbgdefined as
function help {
:
}
while true; do
read -r __cmd?"dbg> "
case "$__cmd" in
'')
break
;;
[h?])
help;;
l)
set|awk '!/.*=/ {exit}; /^[a-z]/' 1>&2;;
L)
set|awk '!/.*=/ {exit}; /^[A-Z_]/' 1>&2;;
Q)
exit;;
*)
trap 'print "\n\"$__cmd\" interrupted!" 1>&2; : ' INT
set|grep "^$__cmd=" 1>&2
(($?)) && eval $__cmd 1>&2
trap - INT
;;
esac
done
- a script (whatever name, let's call it
dbgtest) defined as
trap '. dbg' DEBUG
a='(v1=1 v2=2)'
eval b=$a
:
dbgtest wants to define a compound variable b by evaluating a text representation a of that variable (this is stupid in this example but in actual case, text representation is read from a file etc.). dbg is intended as minimal step-through "debugger". for the problem at hand only the initial break case (break REPL upon CR) is relevant: running ksh dbgtest puts you in the REPL of dbg. upon second CR at the dbg> prompt an error results:
dbgtest[4]: eval[1]: .: dbg: line 1: b.help: invalid discipline function
the error is triggered by the very presence of a function definition preceding the REPL (help in the example). if that function definition is removed the error does not happen (you can hit l after each CR to see the intermediate state of defined variables where I note that intermittendely there are variables called b.v1 and b.v2 which apparently appear temporarily during the eval based construction of final compound variable b).
I do not use or know anything about discipline functions but I seem to get the fact that the error happens because the eval tries to access b.help which is indeed an undefined/non-existent discipline function -- however I do not see that this would not be a bug (or what am I missing?).
seen with Version AJM 93u+m/1.1.0-alpha+c222d956 2025-06-22