aboutsummaryrefslogtreecommitdiff
path: root/stdlib.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib.tcl')
-rw-r--r--stdlib.tcl17
1 files changed, 17 insertions, 0 deletions
diff --git a/stdlib.tcl b/stdlib.tcl
index 9727eb2..fe406ed 100644
--- a/stdlib.tcl
+++ b/stdlib.tcl
@@ -96,3 +96,20 @@ proc errorInfo {msg {stacktrace ""}} {
# Remove the trailing newline
string trim $result
}
+
+# Finds the current executable by searching along the path
+# Returns the empty string if not found.
+proc {info nameofexecutable} {} {
+ if {[info exists ::jim_argv0]} {
+ if {[string first "/" $::jim_argv0] >= 0} {
+ return $::jim_argv0
+ }
+ foreach path [split [env PATH ""] :] {
+ set exec [file join $path $::jim_argv0]
+ if {[file executable $exec]} {
+ return $exec
+ }
+ }
+ }
+ return ""
+}