From e60018c2797b6edb2d05336178c88e429ba62f73 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 30 Oct 2014 19:48:54 +1000 Subject: [PATCH] initjimsh: jim::argv0 is not always available Signed-off-by: Steve Bennett --- initjimsh.tcl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/initjimsh.tcl b/initjimsh.tcl index 7423dfb..f929a27 100644 --- a/initjimsh.tcl +++ b/initjimsh.tcl @@ -6,22 +6,25 @@ proc _jimsh_init {} { global jim::exe jim::argv0 tcl_interactive auto_path tcl_platform # Stash the result of [info nameofexecutable] now, before a possible [cd] - if {[string match "*/*" $jim::argv0]} { - set jim::exe [file join [pwd] $jim::argv0] - } else { - set jim::exe "" - foreach path [split [env PATH ""] $tcl_platform(pathSeparator)] { - set exec [file join [pwd] [string map {\\ /} $path] $jim::argv0] - if {[file executable $exec]} { - set jim::exe $exec - break + if {[exists jim::argv0]} { + if {[string match "*/*" $jim::argv0]} { + set jim::exe [file join [pwd] $jim::argv0] + } else { + foreach path [split [env PATH ""] $tcl_platform(pathSeparator)] { + set exec [file join [pwd] [string map {\\ /} $path] $jim::argv0] + if {[file executable $exec]} { + set jim::exe $exec + break + } } } } # Add to the standard auto_path lappend p {*}[split [env JIMLIB {}] $tcl_platform(pathSeparator)] - lappend p [file dirname $jim::exe] + if {[exists jim::exe]} { + lappend p [file dirname $jim::exe] + } lappend p {*}$auto_path set auto_path $p -- 2.11.4.GIT