diff options
Diffstat (limited to 'stdlib.tcl')
-rw-r--r-- | stdlib.tcl | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 "" +} |