rename(n)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– 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