[25] | 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: rename.n,v 1.5 2004/10/27 14:24:37 dkf Exp $ |
---|
| 9 | '\" |
---|
| 10 | .so man.macros |
---|
| 11 | .TH rename n "" Tcl "Tcl Built-In Commands" |
---|
| 12 | .BS |
---|
| 13 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
| 14 | .SH NAME |
---|
| 15 | rename \- Rename or delete a command |
---|
| 16 | .SH SYNOPSIS |
---|
| 17 | \fBrename \fIoldName newName\fR |
---|
| 18 | .BE |
---|
| 19 | |
---|
| 20 | .SH DESCRIPTION |
---|
| 21 | .PP |
---|
| 22 | Rename the command that used to be called \fIoldName\fR so that it |
---|
| 23 | is now called \fInewName\fR. |
---|
| 24 | If \fInewName\fR is an empty string then \fIoldName\fR is deleted. |
---|
| 25 | \fIoldName\fR and \fInewName\fR may include namespace qualifiers |
---|
| 26 | (names of containing namespaces). |
---|
| 27 | If a command is renamed into a different namespace, |
---|
| 28 | future invocations of it will execute in the new namespace. |
---|
| 29 | The \fBrename\fR command returns an empty string as result. |
---|
| 30 | .SH EXAMPLE |
---|
| 31 | The \fBrename\fR command can be used to wrap the standard Tcl commands |
---|
| 32 | with your own monitoring machinery. For example, you might wish to |
---|
| 33 | count how often the \fBsource\fR command is called: |
---|
| 34 | .CS |
---|
| 35 | \fBrename\fR ::source ::theRealSource |
---|
| 36 | set sourceCount 0 |
---|
| 37 | proc ::source args { |
---|
| 38 | global sourceCount |
---|
| 39 | puts "called source for the [incr sourceCount]'th time" |
---|
| 40 | uplevel 1 ::theRealSource $args |
---|
| 41 | } |
---|
| 42 | .CE |
---|
| 43 | |
---|
| 44 | .SH "SEE ALSO" |
---|
| 45 | namespace(n), proc(n) |
---|
| 46 | |
---|
| 47 | .SH KEYWORDS |
---|
| 48 | command, delete, namespace, rename |
---|