tcl - How to get path of current script? -
sometimes needed current path of script. ways that?
while script being evaluated (but not while procedures being called) current script name (strictly, whatever passed source or c api equivalent, tcl_evalfile() , related) result of info script; it's highly advisable normalise absolute pathname calls cd don't change interpretation.
scripts need information tend put inside themselves:
# *good* use of [variable]… variable mylocation [file normalize [info script]] they can retrieve value (or things derived it) easily:
proc getresourcedirectory {} { variable mylocation return [file dirname $mylocation] } the other common locations are:
$::argv0“main” script (and you're evaluating main script if it's equalinfo script)[info nameofexecutable]tcl interpreter program (typicallyargv[0]@ c level)[info library]tcl's own library scripts located$::tcl_pkgpathtcl list of directories packages installed$::auto_pathtcl list of directories scripts searched (including packages! package path used initialise this.)
Comments
Post a Comment