unknown − Handle attempts to use non-existent commands


unknown cmdName ?arg arg ...? ___________________________


This command is invoked by the Tcl interpreter whenever a script tries to invoke a command that does not exist. The default implementation of unknown is a library procedure defined when Tcl initializes an interpreter. You can override the default unknown to change its functionality, or you can register a new handler for individual namespaces using the namespace unknown command. Note that there is no default implementation of unknown in a safe interpreter.

If the Tcl interpreter encounters a command name for which there is not a defined command (in either the current namespace, or the global namespace), then Tcl checks for the existence of an unknown handler for the current namespace. By default, this handler is a command named ::unknown. If there is no such command, then the interpreter returns an error. If the unknown command exists (or a new handler has been registered for the current namespace), then it is invoked with arguments consisting of the fully-substituted name and arguments for the original non-existent command. The unknown command typically does things like searching through library directories for a command procedure with the name cmdName, or expanding abbreviated command names to full-length, or automatically executing unknown commands as sub-processes. In some cases (such as expanding abbreviations) unknown will change the original command slightly and then (re-)execute it. The result of the unknown command is used as the result for the original non-existent command.

The default implementation of unknown behaves as follows. It first calls the auto_load library procedure to load the command. If this succeeds, then it executes the original command with its original arguments. If the auto-load fails then unknown calls auto_execok to see if there is an executable file by the name cmd. If so, it invokes the Tcl exec command with cmd and all the args as arguments. If cmd cannot be auto-executed, unknown checks to see if the command was invoked at top-level and outside of any script. If so, then unknown takes two additional steps. First, it sees if cmd has one of the following three forms: !!, !event, or ^old^new?^?. If so, then unknown carries out history substitution in the same way that csh would for these constructs. Finally, unknown checks to see if cmd is a unique abbreviation 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, unknown generates an error return. If the global variable auto_noload is defined, then the auto-load step is skipped. If the global variable auto_noexec is defined then the auto-exec step is skipped. Under normal circumstances the return value from unknown is the return value from the command that was eventually executed.


Arrange for the unknown command 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 unknown _original_unknown

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


info(1), proc(5), interp(n), library(n), namespace.conf(5)


error, non-existent command, unknown

More Linux Commands

Tcl_QueueEvent(3) - the event queue and notifier interfaces
The interfaces described here are used to customize the Tcl event loop. The two most common customizations are to add new sources of events and to merge Tcls ev

data(3form) - test for off-screen data in given forms.......
The function data_ahead tests whether there is off-screen data ahead in the given form. It returns TRUE 411toppm(1) or FALSE (0). The function data_behind tests

program_invocation_name(3) - obtain name used to invoke call
program_invocation_name contains the name that was used to invoke the calling program. This is the same as the value of argv[0] in main(), with the difference t

asn1_read_value(3) - Returns the value of one element inside
Returns the value of one element inside a structure. If an element is OPTIONAL and this returns ASN1_ELEMENT_NOT_FOUND, it means that this element wasnt present

pdftops(1) - Portable Document Format (PDF) to PostScript co
Pdftops converts Portable Document Format (PDF) files to PostScript so they can be printed. Pdftops reads the PDF file, PDF-file, and writes a PostScript file,

apparmor_status(8) display various information about the cur
aa-status will report various aspects of the current state of AppArmor confinement. By default, it displays the same information as if the --verbose argument we

tparm(3ncurses) - curses interfaces to terminfo database....
These low-level routines must be called by programs that have to deal directly with the terminfo database to handle certain terminal capabilities, such as progr

dreml(3) - floating-point remainder function (Man Page).....
The remainder() function computes the remainder of dividing x by y. The return value is x-n*y, where n is the value x / y, rounded to the nearest integer. If th

pgmtopgm(1) - copy PGM image (Commands - Linux man page)....
This program is part of Netpbm(1) pgmtopgm simply copies a PGM image from Standard Input to Standard Output. This may seem an unnecessary duplication of cat, bu

XWithdrawWindow(3) - manipulate top-level windows (ManPage)
The XIconifyWindow function sends a WM_CHANGE_STATE ClientMessage event with a format of 32 and a first data element of IconicState (as described in section 4.1

ldap_str2attributetype(3) - Schema definition handling routi
These routines are used to parse schema definitions in the syntax defined in RFC 4512 into structs and handle these structs. These routines handle four kinds of

ggz-wrapper(6) - GGZ Gaming Zone command line core client...
The GGZ Gaming Zone allows people to play many games online using so-called GGZ core clients which are chat clients with integrated game launchers. The ggz-wrap

We can't live, work or learn in freedom unless the software we use is free.