Skip to content

Commit

Permalink
initjimsh: on Windows the current dir is searched first
Browse files Browse the repository at this point in the history
Before the PATH

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information
msteveb committed Oct 27, 2024
1 parent 3a1cbeb commit 79eb6f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions initjimsh.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ proc _jimsh_init {} {
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]
set jim::argv0 [file tail $jim::argv0]
set path [split [env PATH ""] $tcl_platform(pathSeparator)]
if {$tcl_platform(platform) eq "windows"} {
# Windows searches the current directory first, and convert backslashes to slashes
set path [lmap p [list "" {*}$path] { string map {\\ /} $p }]
}
foreach p $path {
set exec [file join [pwd] $p $jim::argv0]
if {[file executable $exec]} {
set jim::exe $exec
break
Expand Down

0 comments on commit 79eb6f6

Please sign in to comment.