1mNAME0m
       unknown - Handle attempts to use non-existent commands

1mSYNOPSIS0m
       1munknown 4m22mcmdName24m ?4marg24m 4marg24m 4m...24m?


1mDESCRIPTION0m
       This  command is invoked by the Tcl interpreter whenever a script tries
       to invoke a command that doesn't exist.  The default implementation  of
       1munknown  22mis  a library procedure defined when Tcl initializes an inter-
       preter.  You can override the default 1munknown 22mto change its functional-
       ity.  Note that there is no default implementation of 1munknown 22min a safe
       interpreter.

       If the Tcl interpreter encounters a command name for which there is not
       a defined command, then Tcl checks for the existence of a command named
       1munknown22m.  If there is no such command, then the interpreter returns  an
       error.   If  the  1munknown 22mcommand exists, then it is invoked with argu-
       ments consisting of the fully-substituted name and  arguments  for  the
       original  non-existent  command.   The  1munknown  22mcommand typically does
       things like searching through library directories for a command  proce-
       dure  with  the name 4mcmdName24m, or expanding abbreviated command names to
       full-length, or automatically executing unknown  commands  as  sub-pro-
       cesses.   In  some cases (such as expanding abbreviations) 1munknown 22mwill
       change the original command slightly and  then  (re-)execute  it.   The
       result  of  the  1munknown 22mcommand is used as the result for the original
       non-existent command.

       The default implementation of 1munknown 22mbehaves  as  follows.   It  first
       calls  the  1mauto_load  22mlibrary  procedure to load the command.  If this
       succeeds, then it executes the original command with its original argu-
       ments.  If the auto-load fails then 1munknown 22mcalls 1mauto_execok 22mto see if
       there is an executable file by the name 4mcmd24m.  If so, it invokes the Tcl
       1mexec  22mcommand  with 4mcmd24m and all the 4margs24m as arguments.  If 4mcmd24m can't be
       auto-executed, 1munknown 22mchecks to see if the command was invoked at top-
       level  and  outside of any script.  If so, then 1munknown 22mtakes two addi-
       tional steps.  First, it sees if 4mcmd24m has one  of  the  following  three
       forms:  1m!!22m,  1m!4m22mevent24m,  or  1m^4m22mold24m1m^4m22mnew24m?1m^22m?.  If so, then 1munknown 22mcarries out
       history substitution in the same way that  1mcsh  22mwould  for  these  con-
       structs.   Finally,  1munknown 22mchecks to see if 4mcmd24m is a unique abbrevia-
       tion for an existing Tcl command.  If so, it expands the  command  name
       and  executes  the command with the original arguments.  If none of the
       above efforts has been able to execute the command,  1munknown  22mgenerates
       an  error  return.  If the global variable 1mauto_noload 22mis defined, then
       the auto-load step is skipped.  If the global variable  1mauto_noexec  22mis
       defined then the auto-exec step is skipped.  Under normal circumstances
       the return value from 1munknown 22mis the return value from the command that
       was eventually executed.

1mEXAMPLE0m
       Arrange  for  the  1munknown 22mcommand to have its standard behavior except
       for first logging the fact that a command was not found:

              # Save the original one so we can chain to it
              rename 1munknown 22m_original_unknown

              # Provide our own implementation
              proc 1munknown 22margs {
                  puts stderr "WARNING: unknown command: $args"
                  uplevel 1 [list _original_unknown {expand}$args]
              }


1mSEE ALSO0m
       info(n), proc(n), interp(n), library(n)


1mKEYWORDS0m
