info procs

info procs ?pattern?

If pattern isn't specified, returns a list of all the names of Tcl procedures in the current namespace. If pattern is specified, only those procedure names in the current namespace matching pattern are returned. Matching is determined using the same rules as for string match.


RCN - Why is exit not listed in info procs?

Because the exit command is not a proc.

In other words:

% info procs exit
% info commands exit
exit
%

How come renaming exit will not make it visible in info procs?

Because giving a command a new name does not convert it from a non-proc command into a proc.

puts "PROCS BEFORE: [lsort [info procs]]"

rename exit __super_exit
rename unknown __super_unknown
proc exit {{code 0}} {
    puts "Why are you leaving me :-("
    __super_exit $code
}

puts "PROCS AFTER: [lsort [info procs]]"
exit

RCN - Thanks, so I guess what you are saying is that since "exit" is not written in tcl, it will not appear in info procs. Is there an introspection way to figure out if commands or procs have been renamed? Other than wrapping rename to track rename calls.

The above code outputs:

PROCS BEFORE: auto_execok auto_import auto_load auto_load_index auto_qualify tclLog unknown
PROCS AFTER: __super_unknown auto_execok auto_import auto_load auto_load_index auto_qualify exit tclLog
Why are you leaving me :-(

However, that doesn't answer, directly, RCN's question.

The info commands and info procs allow you to determine if there is something named exit, for example, currently in effect. The info body command tells you what a proc's code is. However, for something like exit, there isn't an equivalent of info body (of course, because these are compiled pieces of code...).

The best you can do is try to check to see if the code in question is a proc, and if so, compare the results of info body to what you believe is the original proc body, to see if something has changed. Oh, and you can see if something you know to be a compiled procedure is now a tcl proc...


See also: