1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1993 The Regents of the University of California.
|
3 |
|
|
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
4 |
|
|
'\"
|
5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
7 |
|
|
'\"
|
8 |
|
|
'\" RCS: @(#) $Id: unknown.n,v 1.1.1.1 2002-01-16 10:25:25 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH unknown n "" Tcl "Tcl Built-In Commands"
|
12 |
|
|
.BS
|
13 |
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
14 |
|
|
.SH NAME
|
15 |
|
|
unknown \- Handle attempts to use non-existent commands
|
16 |
|
|
.SH SYNOPSIS
|
17 |
|
|
\fBunknown \fIcmdName \fR?\fIarg arg ...\fR?
|
18 |
|
|
.BE
|
19 |
|
|
|
20 |
|
|
.SH DESCRIPTION
|
21 |
|
|
.PP
|
22 |
|
|
This command is invoked by the Tcl interpreter whenever a script
|
23 |
|
|
tries to invoke a command that doesn't exist. The implementation
|
24 |
|
|
of \fBunknown\fR isn't part of the Tcl core; instead, it is a
|
25 |
|
|
library procedure defined by default when Tcl starts up. You
|
26 |
|
|
can override the default \fBunknown\fR to change its functionality.
|
27 |
|
|
.PP
|
28 |
|
|
If the Tcl interpreter encounters a command name for which there
|
29 |
|
|
is not a defined command, then Tcl checks for the existence of
|
30 |
|
|
a command named \fBunknown\fR.
|
31 |
|
|
If there is no such command, then the interpreter returns an
|
32 |
|
|
error.
|
33 |
|
|
If the \fBunknown\fR command exists, then it is invoked with
|
34 |
|
|
arguments consisting of the fully-substituted name and arguments
|
35 |
|
|
for the original non-existent command.
|
36 |
|
|
The \fBunknown\fR command typically does things like searching
|
37 |
|
|
through library directories for a command procedure with the name
|
38 |
|
|
\fIcmdName\fR, or expanding abbreviated command names to full-length,
|
39 |
|
|
or automatically executing unknown commands as sub-processes.
|
40 |
|
|
In some cases (such as expanding abbreviations) \fBunknown\fR will
|
41 |
|
|
change the original command slightly and then (re-)execute it.
|
42 |
|
|
The result of the \fBunknown\fR command is used as the result for
|
43 |
|
|
the original non-existent command.
|
44 |
|
|
.PP
|
45 |
|
|
The default implementation of \fBunknown\fR behaves as follows.
|
46 |
|
|
It first calls the \fBauto_load\fR library procedure to load the command.
|
47 |
|
|
If this succeeds, then it executes the original command with its
|
48 |
|
|
original arguments.
|
49 |
|
|
If the auto-load fails then \fBunknown\fR calls \fBauto_execok\fR
|
50 |
|
|
to see if there is an executable file by the name \fIcmd\fR.
|
51 |
|
|
If so, it invokes the Tcl \fBexec\fR command
|
52 |
|
|
with \fIcmd\fR and all the \fIargs\fR as arguments.
|
53 |
|
|
If \fIcmd\fR can't be auto-executed, \fBunknown\fR checks to
|
54 |
|
|
see if the command was invoked at top-level and outside of any
|
55 |
|
|
script. If so, then \fBunknown\fR takes two additional steps.
|
56 |
|
|
First, it sees if \fIcmd\fR has one of the following three forms:
|
57 |
|
|
\fB!!\fR, \fB!\fIevent\fR, or \fB^\fIold\fB^\fInew\fR?\fB^\fR?.
|
58 |
|
|
If so, then \fBunknown\fR carries out history substitution
|
59 |
|
|
in the same way that \fBcsh\fR would for these constructs.
|
60 |
|
|
Finally, \fBunknown\fR checks to see if \fIcmd\fR is
|
61 |
|
|
a unique abbreviation for an existing Tcl command.
|
62 |
|
|
If so, it expands the command name and executes the command with
|
63 |
|
|
the original arguments.
|
64 |
|
|
If none of the above efforts has been able to execute
|
65 |
|
|
the command, \fBunknown\fR generates an error return.
|
66 |
|
|
If the global variable \fBauto_noload\fR is defined, then the auto-load
|
67 |
|
|
step is skipped.
|
68 |
|
|
If the global variable \fBauto_noexec\fR is defined then the
|
69 |
|
|
auto-exec step is skipped.
|
70 |
|
|
Under normal circumstances the return value from \fBunknown\fR
|
71 |
|
|
is the return value from the command that was eventually
|
72 |
|
|
executed.
|
73 |
|
|
|
74 |
|
|
.SH KEYWORDS
|
75 |
|
|
error, non-existent command
|