rename(n)
π rename(n) β the Tcl Built-In Commands glow-up π
okay bestie, welcome to rename(n), straight out of the Tcl Built-In Commands lineup, and honestly? she's a tiny little icon. one job, does it flawlessly. let's get into it β¨
πΈ NAME πΈ
rename β Rename or delete a command π
β¨ SYNOPSIS β¨
rename oldName newName
that's it. two args. no drama. periodt π
π¦ DESCRIPTION π¦
so here's the tea β: rename takes the command that used to be called oldName and renames it so that it's now called newName. glow-up complete, no cap.
and if newName is an empty string, then oldName gets deleted. gone. ghosted. it's giving "we don't talk anymore" ππ
now, both oldName and newName are allowed to include namespace qualifiers (aka the names of the containing namespaces). and here's the part you gotta remember, fr fr: if a command gets renamed into a different namespace, then every future invocation of it will execute in that new namespace. she moves houses, she lives there now. main character relocation energy π
and the result? rename returns an empty string as its result. that's it. nothing. silence. elegant. π«Ά
π EXAMPLE π
okay so this is actually so smart β you can use rename to wrap the standard Tcl commands with your own monitoring machinery. like, imagine you wanna count how many times the source command gets called. obsessed. here's how:
rename ::source ::theRealSource
set sourceCount 0
proc ::source args {
global sourceCount
puts "called source for the [incr sourceCount]'th time"
uplevel 1 ::theRealSource $args
}
see what she did?? she renamed the real one out of the way, then slid her own ::source in to do the counting, and called the original with uplevel. genius behavior honestly πβ¨
π SEE ALSO π
go read those too, bestie, they're the friend group π
β KEYWORDS β
command, delete, namespace, rename
iykyk π§
and that's the whole page, bestie!! this one came to you from Tcl β yep, the rename(n) page itself, Tcl Built-In Commands energy through and through ππ thanks for reading, mwah, slay, bye!! π¦πΈπ
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- Copyright (c) 1993 The Regents of the University of California
- Copyright (c) 1994-1997 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms