1 | '\" |
---|
2 | '\" Copyright (c) 1993 The Regents of the University of California. |
---|
3 | '\" Copyright (c) 1994-1997 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: tclvars.n,v 1.35 2007/12/13 15:22:33 dgp Exp $ |
---|
9 | '\" |
---|
10 | .so man.macros |
---|
11 | .TH tclvars n 8.0 Tcl "Tcl Built-In Commands" |
---|
12 | .BS |
---|
13 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
14 | .SH NAME |
---|
15 | tclvars \- Variables used by Tcl |
---|
16 | .BE |
---|
17 | .SH DESCRIPTION |
---|
18 | .PP |
---|
19 | The following global variables are created and managed automatically |
---|
20 | by the Tcl library. Except where noted below, these variables should |
---|
21 | normally be treated as read-only by application-specific code and by users. |
---|
22 | .TP |
---|
23 | \fBenv\fR |
---|
24 | This variable is maintained by Tcl as an array |
---|
25 | whose elements are the environment variables for the process. |
---|
26 | Reading an element will return the value of the corresponding |
---|
27 | environment variable. |
---|
28 | Setting an element of the array will modify the corresponding |
---|
29 | environment variable or create a new one if it does not already |
---|
30 | exist. |
---|
31 | Unsetting an element of \fBenv\fR will remove the corresponding |
---|
32 | environment variable. |
---|
33 | Changes to the \fBenv\fR array will affect the environment |
---|
34 | passed to children by commands like \fBexec\fR. |
---|
35 | If the entire \fBenv\fR array is unset then Tcl will stop |
---|
36 | monitoring \fBenv\fR accesses and will not update environment |
---|
37 | variables. |
---|
38 | .RS |
---|
39 | .PP |
---|
40 | Under Windows, the environment variables PATH and COMSPEC in any |
---|
41 | capitalization are converted automatically to upper case. For instance, the |
---|
42 | PATH variable could be exported by the operating system as |
---|
43 | .QW path , |
---|
44 | .QW Path , |
---|
45 | .QW PaTh , |
---|
46 | etc., causing otherwise simple Tcl code to have to |
---|
47 | support many special cases. All other environment variables inherited by |
---|
48 | Tcl are left unmodified. Setting an env array variable to blank is the |
---|
49 | same as unsetting it as this is the behavior of the underlying Windows OS. |
---|
50 | It should be noted that relying on an existing and empty environment variable |
---|
51 | will not work on Windows and is discouraged for cross-platform usage. |
---|
52 | .RE |
---|
53 | .TP |
---|
54 | \fBerrorCode\fR |
---|
55 | This variable holds the value of the \fB\-errorcode\fR return option |
---|
56 | set by the most recent error that occurred in this interpreter. |
---|
57 | This list value represents additional information about the error |
---|
58 | in a form that is easy to process with programs. |
---|
59 | The first element of the list identifies a general class of |
---|
60 | errors, and determines the format of the rest of the list. |
---|
61 | The following formats for \fB\-errorcode\fR return options |
---|
62 | are used by the Tcl core; individual applications may define |
---|
63 | additional formats. |
---|
64 | .RS |
---|
65 | .TP |
---|
66 | \fBARITH\fI code msg\fR |
---|
67 | . |
---|
68 | This format is used when an arithmetic error occurs (e.g. an attempt |
---|
69 | to divide zero by zero in the \fBexpr\fR command). |
---|
70 | \fICode\fR identifies the precise error and \fImsg\fR provides a |
---|
71 | human-readable description of the error. \fICode\fR will be either |
---|
72 | DIVZERO (for an attempt to divide by zero), |
---|
73 | DOMAIN (if an argument is outside the domain of a function, such as acos(\-3)), |
---|
74 | IOVERFLOW (for integer overflow), |
---|
75 | OVERFLOW (for a floating-point overflow), |
---|
76 | or UNKNOWN (if the cause of the error cannot be determined). |
---|
77 | .RS |
---|
78 | .PP |
---|
79 | Detection of these errors depends in part on the underlying hardware |
---|
80 | and system libraries. |
---|
81 | .RE |
---|
82 | .TP |
---|
83 | \fBCHILDKILLED\fI pid sigName msg\fR |
---|
84 | This format is used when a child process has been killed because of |
---|
85 | a signal. The \fIpid\fR element will be the process's identifier (in decimal). |
---|
86 | The \fIsigName\fR element will be the symbolic name of the signal that caused |
---|
87 | the process to terminate; it will be one of the names from the |
---|
88 | include file signal.h, such as \fBSIGPIPE\fR. |
---|
89 | The \fImsg\fR element will be a short human-readable message |
---|
90 | describing the signal, such as |
---|
91 | .QW "write on pipe with no readers" |
---|
92 | for \fBSIGPIPE\fR. |
---|
93 | .TP |
---|
94 | \fBCHILDSTATUS\fI pid code\fR |
---|
95 | This format is used when a child process has exited with a non-zero |
---|
96 | exit status. The \fIpid\fR element will be the |
---|
97 | process's identifier (in decimal) and the \fIcode\fR element will be the exit |
---|
98 | code returned by the process (also in decimal). |
---|
99 | .TP |
---|
100 | \fBCHILDSUSP\fI pid sigName msg\fR |
---|
101 | This format is used when a child process has been suspended because |
---|
102 | of a signal. |
---|
103 | The \fIpid\fR element will be the process's identifier, in decimal. |
---|
104 | The \fIsigName\fR element will be the symbolic name of the signal that caused |
---|
105 | the process to suspend; this will be one of the names from the |
---|
106 | include file signal.h, such as \fBSIGTTIN\fR. |
---|
107 | The \fImsg\fR element will be a short human-readable message |
---|
108 | describing the signal, such as |
---|
109 | .QW "background tty read" |
---|
110 | for \fBSIGTTIN\fR. |
---|
111 | .TP |
---|
112 | \fBNONE\fR |
---|
113 | This format is used for errors where no additional information is |
---|
114 | available for an error besides the message returned with the |
---|
115 | error. In these cases the \fB\-errorcode\fR return option |
---|
116 | will consist of a list containing a single element whose |
---|
117 | contents are \fBNONE\fR. |
---|
118 | .TP |
---|
119 | \fBPOSIX \fIerrName msg\fR |
---|
120 | If the first element is \fBPOSIX\fR, then |
---|
121 | the error occurred during a POSIX kernel call. |
---|
122 | The \fIerrName\fR element will contain the symbolic name |
---|
123 | of the error that occurred, such as \fBENOENT\fR; this will |
---|
124 | be one of the values defined in the include file errno.h. |
---|
125 | The \fImsg\fR element will be a human-readable |
---|
126 | message corresponding to \fIerrName\fR, such as |
---|
127 | .QW "no such file or directory" |
---|
128 | for the \fBENOENT\fR case. |
---|
129 | .PP |
---|
130 | To set the \fB\-errorcode\fR return option, applications should use library |
---|
131 | procedures such as \fBTcl_SetObjErrorCode\fR, \fBTcl_SetReturnOptions\fR, |
---|
132 | and \fBTcl_PosixError\fR, or they may invoke the \fB\-errorcode\fR |
---|
133 | option of the \fBreturn\fR command. |
---|
134 | If none of these methods for setting the error code has been used, |
---|
135 | the Tcl interpreter will reset the variable to \fBNONE\fR after |
---|
136 | the next error. |
---|
137 | .RE |
---|
138 | .\" .TP |
---|
139 | .\" \fBTCL\fR ... |
---|
140 | .\" . |
---|
141 | .\" Indicates some sort of problem generated in relation to Tcl itself, |
---|
142 | .\" e.g. a failure to look up a channel or variable. |
---|
143 | .TP |
---|
144 | \fBerrorInfo\fR |
---|
145 | This variable holds the value of the \fB\-errorinfo\fR return option |
---|
146 | set by the most recent error that occurred in this interpreter. |
---|
147 | This string value will contain one or more lines |
---|
148 | identifying the Tcl commands and procedures that were being executed |
---|
149 | when the most recent error occurred. |
---|
150 | Its contents take the form of a stack trace showing the various |
---|
151 | nested Tcl commands that had been invoked at the time of the error. |
---|
152 | .TP |
---|
153 | \fBtcl_library\fR |
---|
154 | This variable holds the name of a directory containing the |
---|
155 | system library of Tcl scripts, such as those used for auto-loading. |
---|
156 | The value of this variable is returned by the \fBinfo library\fR command. |
---|
157 | See the \fBlibrary\fR manual entry for details of the facilities |
---|
158 | provided by the Tcl script library. |
---|
159 | Normally each application or package will have its own application-specific |
---|
160 | script library in addition to the Tcl script library; |
---|
161 | each application should set a global variable with a name like |
---|
162 | \fB$\fIapp\fB_library\fR (where \fIapp\fR is the application's name) |
---|
163 | to hold the network file name for that application's library directory. |
---|
164 | The initial value of \fBtcl_library\fR is set when an interpreter |
---|
165 | is created by searching several different directories until one is |
---|
166 | found that contains an appropriate Tcl startup script. |
---|
167 | If the \fBTCL_LIBRARY\fR environment variable exists, then |
---|
168 | the directory it names is checked first. |
---|
169 | If \fBTCL_LIBRARY\fR is not set or doesn't refer to an appropriate |
---|
170 | directory, then Tcl checks several other directories based on a |
---|
171 | compiled-in default location, the location of the binary containing |
---|
172 | the application, and the current working directory. |
---|
173 | .TP |
---|
174 | \fBtcl_patchLevel\fR |
---|
175 | . |
---|
176 | When an interpreter is created Tcl initializes this variable to |
---|
177 | hold a string giving the current patch level for Tcl, such as |
---|
178 | \fB8.4.16\fR for Tcl 8.4 with the first sixteen official patches, or |
---|
179 | \fB8.5b3\fR for the third beta release of Tcl 8.5. |
---|
180 | The value of this variable is returned by the \fBinfo patchlevel\fR |
---|
181 | command. |
---|
182 | .TP |
---|
183 | \fBtcl_pkgPath\fR |
---|
184 | This variable holds a list of directories indicating where packages are |
---|
185 | normally installed. It is not used on Windows. It typically contains |
---|
186 | either one or two entries; if it contains two entries, the first is |
---|
187 | normally a directory for platform-dependent packages (e.g., shared library |
---|
188 | binaries) and the second is normally a directory for platform-independent |
---|
189 | packages (e.g., script files). Typically a package is installed as a |
---|
190 | subdirectory of one of the entries in \fB$tcl_pkgPath\fR. The directories |
---|
191 | in \fB$tcl_pkgPath\fR are included by default in the \fBauto_path\fR |
---|
192 | variable, so they and their immediate subdirectories are automatically |
---|
193 | searched for packages during \fBpackage require\fR commands. Note: |
---|
194 | \fBtcl_pkgPath\fR is not intended to be modified by the application. Its |
---|
195 | value is added to \fBauto_path\fR at startup; changes to \fBtcl_pkgPath\fR |
---|
196 | are not reflected in \fBauto_path\fR. If you want Tcl to search additional |
---|
197 | directories for packages you should add the names of those directories to |
---|
198 | \fBauto_path\fR, not \fBtcl_pkgPath\fR. |
---|
199 | .TP |
---|
200 | \fBtcl_platform\fR |
---|
201 | This is an associative array whose elements contain information about |
---|
202 | the platform on which the application is running, such as the name of |
---|
203 | the operating system, its current release number, and the machine's |
---|
204 | instruction set. The elements listed below will always |
---|
205 | be defined, but they may have empty strings as values if Tcl could not |
---|
206 | retrieve any relevant information. In addition, extensions |
---|
207 | and applications may add additional values to the array. The |
---|
208 | predefined elements are: |
---|
209 | .RS |
---|
210 | .TP |
---|
211 | \fBbyteOrder\fR |
---|
212 | The native byte order of this machine: either \fBlittleEndian\fR or |
---|
213 | \fBbigEndian\fR. |
---|
214 | .TP |
---|
215 | \fBdebug\fR |
---|
216 | If this variable exists, then the interpreter was compiled with and linked |
---|
217 | to a debug-enabled C run-time. This variable will only exist on Windows, |
---|
218 | so extension writers can specify which package to load depending on the |
---|
219 | C run-time library that is in use. This is not an indication that this core |
---|
220 | contains symbols. |
---|
221 | .TP |
---|
222 | \fBmachine\fR |
---|
223 | The instruction set executed by this machine, such as |
---|
224 | \fBintel\fR, \fBPPC\fR, \fB68k\fR, or \fBsun4m\fR. On UNIX machines, this |
---|
225 | is the value returned by \fBuname -m\fR. |
---|
226 | .TP |
---|
227 | \fBos\fR |
---|
228 | The name of the operating system running on this machine, |
---|
229 | such as \fBWindows 95\fR, \fBWindows NT\fR, or \fBSunOS\fR. |
---|
230 | On UNIX machines, this is the value returned by \fBuname -s\fR. |
---|
231 | On Windows 95 and Windows 98, the value returned will be \fBWindows |
---|
232 | 95\fR to provide better backwards compatibility to Windows 95; to |
---|
233 | distinguish between the two, check the \fBosVersion\fR. |
---|
234 | .TP |
---|
235 | \fBosVersion\fR |
---|
236 | The version number for the operating system running on this machine. |
---|
237 | On UNIX machines, this is the value returned by \fBuname -r\fR. On |
---|
238 | Windows 95, the version will be 4.0; on Windows 98, the version will |
---|
239 | be 4.10. |
---|
240 | .TP |
---|
241 | \fBplatform\fR |
---|
242 | Either \fBwindows\fR, or \fBunix\fR. This identifies the |
---|
243 | general operating environment of the machine. |
---|
244 | .TP |
---|
245 | \fBthreaded\fR |
---|
246 | If this variable exists, then the interpreter |
---|
247 | was compiled with threads enabled. |
---|
248 | .TP |
---|
249 | \fBuser\fR |
---|
250 | This identifies the |
---|
251 | current user based on the login information available on the platform. |
---|
252 | This comes from the USER or LOGNAME environment variable on Unix, |
---|
253 | and the value from GetUserName on Windows. |
---|
254 | .TP |
---|
255 | \fBwordSize\fR |
---|
256 | This gives the size of the native-machine word in bytes (strictly, it |
---|
257 | is same as the result of evaluating \fIsizeof(long)\fR in C.) |
---|
258 | .TP |
---|
259 | \fBpointerSize\fR |
---|
260 | This gives the size of the native-machine pointer in bytes (strictly, it |
---|
261 | is same as the result of evaluating \fIsizeof(void*)\fR in C.) |
---|
262 | .RE |
---|
263 | .TP |
---|
264 | \fBtcl_precision\fR |
---|
265 | This variable controls the number of digits to generate |
---|
266 | when converting floating-point values to strings. It defaults |
---|
267 | .VS 8.5 |
---|
268 | to 0. \fIApplications should not change this value;\fR it is |
---|
269 | provided for compatibility with legacy code. |
---|
270 | .PP |
---|
271 | .RS |
---|
272 | The default value of 0 is special, meaning that Tcl should |
---|
273 | convert numbers using as few digits as possible while still |
---|
274 | distinguishing any floating point number from its nearest |
---|
275 | neighbours. It differs from using an arbitrarily high value |
---|
276 | for \fItcl_precision\fR in that an inexact number like \fI1.4\fR |
---|
277 | will convert as \fI1.4\fR rather than \fI1.3999999999999999\fR |
---|
278 | even though the latter is nearer to the exact value of the |
---|
279 | binary number. |
---|
280 | .RE |
---|
281 | .VE 8.5 |
---|
282 | .PP |
---|
283 | .RS |
---|
284 | 17 digits is |
---|
285 | .QW perfect |
---|
286 | for IEEE floating-point in that it allows |
---|
287 | double-precision values to be converted to strings and back to |
---|
288 | binary with no loss of information. However, using 17 digits prevents |
---|
289 | any rounding, which produces longer, less intuitive results. For example, |
---|
290 | \fBexpr {1.4}\fR returns 1.3999999999999999 with \fBtcl_precision\fR |
---|
291 | set to 17, vs. 1.4 if \fBtcl_precision\fR is 12. |
---|
292 | .RE |
---|
293 | .PP |
---|
294 | .RS |
---|
295 | All interpreters in a thread share a single \fBtcl_precision\fR value: |
---|
296 | changing it in one interpreter will affect all other interpreters as |
---|
297 | well. However, safe interpreters are not allowed to modify the |
---|
298 | variable. |
---|
299 | .RE |
---|
300 | .TP |
---|
301 | \fBtcl_rcFileName\fR |
---|
302 | This variable is used during initialization to indicate the name of a |
---|
303 | user-specific startup file. If it is set by application-specific |
---|
304 | initialization, then the Tcl startup code will check for the existence |
---|
305 | of this file and \fBsource\fR it if it exists. For example, for \fBwish\fR |
---|
306 | the variable is set to \fB~/.wishrc\fR for Unix and \fB~/wishrc.tcl\fR |
---|
307 | for Windows. |
---|
308 | .TP |
---|
309 | \fBtcl_traceCompile\fR |
---|
310 | The value of this variable can be set to control |
---|
311 | how much tracing information |
---|
312 | is displayed during bytecode compilation. |
---|
313 | By default, tcl_traceCompile is zero and no information is displayed. |
---|
314 | Setting tcl_traceCompile to 1 generates a one-line summary in stdout |
---|
315 | whenever a procedure or top-level command is compiled. |
---|
316 | Setting it to 2 generates a detailed listing in stdout of the |
---|
317 | bytecode instructions emitted during every compilation. |
---|
318 | This variable is useful in |
---|
319 | tracking down suspected problems with the Tcl compiler. |
---|
320 | .PP |
---|
321 | .RS |
---|
322 | This variable and functionality only exist if |
---|
323 | \fBTCL_COMPILE_DEBUG\fR was defined during Tcl's compilation. |
---|
324 | .RE |
---|
325 | .TP |
---|
326 | \fBtcl_traceExec\fR |
---|
327 | The value of this variable can be set to control |
---|
328 | how much tracing information |
---|
329 | is displayed during bytecode execution. |
---|
330 | By default, tcl_traceExec is zero and no information is displayed. |
---|
331 | Setting tcl_traceExec to 1 generates a one-line trace in stdout |
---|
332 | on each call to a Tcl procedure. |
---|
333 | Setting it to 2 generates a line of output |
---|
334 | whenever any Tcl command is invoked |
---|
335 | that contains the name of the command and its arguments. |
---|
336 | Setting it to 3 produces a detailed trace showing the result of |
---|
337 | executing each bytecode instruction. |
---|
338 | Note that when tcl_traceExec is 2 or 3, |
---|
339 | commands such as \fBset\fR and \fBincr\fR |
---|
340 | that have been entirely replaced by a sequence |
---|
341 | of bytecode instructions are not shown. |
---|
342 | Setting this variable is useful in |
---|
343 | tracking down suspected problems with the bytecode compiler |
---|
344 | and interpreter. |
---|
345 | .PP |
---|
346 | .RS |
---|
347 | This variable and functionality only exist if |
---|
348 | \fBTCL_COMPILE_DEBUG\fR was defined during Tcl's compilation. |
---|
349 | .RE |
---|
350 | .TP |
---|
351 | \fBtcl_wordchars\fR |
---|
352 | The value of this variable is a regular expression that can be set to |
---|
353 | control what are considered |
---|
354 | .QW word |
---|
355 | characters, for instances like |
---|
356 | selecting a word by double-clicking in text in Tk. It is platform |
---|
357 | dependent. On Windows, it defaults to \fB\eS\fR, meaning anything |
---|
358 | but a Unicode space character. Otherwise it defaults to \fB\ew\fR, |
---|
359 | which is any Unicode word character (number, letter, or underscore). |
---|
360 | .TP |
---|
361 | \fBtcl_nonwordchars\fR |
---|
362 | The value of this variable is a regular expression that can be set to |
---|
363 | control what are considered |
---|
364 | .QW non-word |
---|
365 | characters, for instances like |
---|
366 | selecting a word by double-clicking in text in Tk. It is platform |
---|
367 | dependent. On Windows, it defaults to \fB\es\fR, meaning any Unicode space |
---|
368 | character. Otherwise it defaults to \fB\eW\fR, which is anything but a |
---|
369 | Unicode word character (number, letter, or underscore). |
---|
370 | .TP |
---|
371 | \fBtcl_version\fR |
---|
372 | When an interpreter is created Tcl initializes this variable to |
---|
373 | hold the version number for this version of Tcl in the form \fIx.y\fR. |
---|
374 | Changes to \fIx\fR represent major changes with probable |
---|
375 | incompatibilities and changes to \fIy\fR represent small enhancements and |
---|
376 | bug fixes that retain backward compatibility. |
---|
377 | The value of this variable is returned by the \fBinfo tclversion\fR |
---|
378 | command. |
---|
379 | .SH "OTHER GLOBAL VARIABLES" |
---|
380 | The following variables are only guaranteed to exist in \fBtclsh\fR |
---|
381 | and \fBwish\fR executables; the Tcl library does not define them |
---|
382 | itself but many Tcl environments do. |
---|
383 | .TP 6 |
---|
384 | \fBargc\fR |
---|
385 | The number of arguments to \fBtclsh\fR or \fBwish\fR. |
---|
386 | .TP 6 |
---|
387 | \fBargv\fR |
---|
388 | Tcl list of arguments to \fBtclsh\fR or \fBwish\fR. |
---|
389 | .TP 6 |
---|
390 | \fBargv0\fR |
---|
391 | The script that \fBtclsh\fR or \fBwish\fR started executing (if it was |
---|
392 | specified) or otherwise the name by which \fBtclsh\fR or \fBwish\fR |
---|
393 | was invoked. |
---|
394 | .TP 6 |
---|
395 | \fBtcl_interactive\fR |
---|
396 | Contains 1 if \fBtclsh\fR or \fBwish\fR is running interactively (no |
---|
397 | script was specified and standard input is a terminal-like device), 0 |
---|
398 | otherwise. |
---|
399 | .PP |
---|
400 | The \fBwish\fR executable additionally specifies the following global |
---|
401 | variable: |
---|
402 | .TP 6 |
---|
403 | \fBgeometry\fR |
---|
404 | If set, contains the user-supplied geometry specification to use for |
---|
405 | the main Tk window. |
---|
406 | .SH "SEE ALSO" |
---|
407 | eval(n), tclsh(1), wish(1) |
---|
408 | .SH KEYWORDS |
---|
409 | arithmetic, bytecode, compiler, error, environment, POSIX, precision, subprocess, variables |
---|