aboutsummaryrefslogtreecommitdiff
path: root/stdlib.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-10-28 09:19:20 +1000
committerSteve Bennett <steveb@workware.net.au>2014-10-28 09:24:37 +1000
commit7cc11e7898250b5551da49ce1e719fcd8311c664 (patch)
treee9a11fd9f265464030f7bf8f73aec50cb530a235 /stdlib.tcl
parent28442e31d396752efa039fee7c2d805ba3a3d92c (diff)
downloadjimtcl-7cc11e7898250b5551da49ce1e719fcd8311c664.zip
jimtcl-7cc11e7898250b5551da49ce1e719fcd8311c664.tar.gz
jimtcl-7cc11e7898250b5551da49ce1e719fcd8311c664.tar.bz2
Fix [info nameofexecutable] after [cd]
If argv0 is a relative path, [info nameofexecutable] returned the wrong result after changing directory. So calculate and stash the result during init. Also move internal $jim_argv0 into namespace jim as $jim::argv0 Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'stdlib.tcl')
-rw-r--r--stdlib.tcl17
1 files changed, 4 insertions, 13 deletions
diff --git a/stdlib.tcl b/stdlib.tcl
index d0256d0..3a2bbd8 100644
--- a/stdlib.tcl
+++ b/stdlib.tcl
@@ -79,21 +79,12 @@ proc errorInfo {msg {stacktrace ""}} {
string trim $result
}
-# Finds the current executable by searching along the path
-# Returns the empty string if not found.
+# Needs to be set up by the container app (e.g. jimsh)
+# Returns the empty string if unknown
proc {info nameofexecutable} {} {
- if {[info exists ::jim_argv0]} {
- if {[string match "*/*" $::jim_argv0]} {
- return [file join [pwd] $::jim_argv0]
- }
- foreach path [split [env PATH ""] $::tcl_platform(pathSeparator)] {
- set exec [file join [pwd] [string map {\\ /} $path] $::jim_argv0]
- if {[file executable $exec]} {
- return $exec
- }
- }
+ if {[exists ::jim::exe]} {
+ return $::jim::exe
}
- return ""
}
# Script-based implementation of 'dict with'