Version 4 of Finding out tclConfig.sh

Updated 2004-11-14 11:58:53 by ecs

Lets exchange here our solutions to finding out tclConfig.sh.


DGP Let's put the correct solution first:

  package require Tcl 8.5
  set d [::tcl::pkgconfig get libdir,install]
  puts [file join $d tclConfig.sh]
  exit

For the large number of people not yet using Tcl 8.5, continue...


Googie My first candidate is following code:

 foreach d "
     $tcl_library
     [lindex $tcl_pkgPath 0]
     $auto_path
     [file dirname $tcl_library]
     [file dirname [lindex $tcl_pkgPath 0]]
     [file dirname [file dirname $tcl_library]]
     [file dirname [file dirname [lindex $tcl_pkgPath 0]]]
     [file dirname [file dirname [file dirname $tcl_library]]]
     [file dirname [file dirname [file dirname [lindex $tcl_pkgPath 0]]]]
 " {
     if {[file exists [file join $d tclConfig.sh]]} {
         puts "[file join $d tclConfig.sh]"
         exit
     }
 }

 puts "none"

We can put it into the one tcl script file and execute from a shell to get info, if we can find tclConfig.sh (returns path pointing to it) or we can't (returns "none"). I use few levels of file dirname for $tcl_library and $tcl_pkgPath, because of some problems on MacOS (tclConfig.sh is places few levels upper than $tcl_library).