Sujet : is there a nicer way to set the Tcl module path?
De : m.n.summerfield (at) *nospam* gmail.com (Mark Summerfield)
Groupes : comp.lang.tclDate : 02. Jul 2025, 12:33:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <10435ed$3dr0l$3@dont-email.me>
User-Agent : Pan/0.154 (Izium; 517acf4)
I like using Tcl modules for my apps.
I also often use soft links so that for example, an app in, say,
~/app/tcl/myapp
will be soft linked to a dir in my $PATH e.g.,
cd ~/bin ; ln -s ~/app/tcl/myapp/myapp.tcl
This means that [info script] will return different paths depending
on whether the app is run in its own dir, ./myapp.tcl or via the
soft link.
So I begin my apps like this:
#!/usr/bin/env tclsh9
if {![catch {file readlink [info script]} name]} {
const APPPATH [file dirname $name]
} else {
const APPPATH [file normalize [file dirname [info script]]]
}
tcl::tm::path add $APPPATH
package require app
app::main
Is there a nicer (and more compact) way to set APPPATH?