Tcl Source Code

Artifact [1fec038d9b]
Login

Artifact 1fec038d9b8e5239d2e9f9d65e1af43434cbdc56:

Attachment "init.patch" to ticket [3546275fff] added by danckaert 2012-07-20 16:57:22.
diff --git a/library/init.tcl b/library/init.tcl
index d8de540..1ea6807 100644
--- a/library/init.tcl
+++ b/library/init.tcl
@@ -689,13 +689,15 @@ proc auto_execok name {
 	}
     }
 
-    foreach dir [split $path {;}] {
-	# Skip already checked directories
-	if {[info exists checked($dir)] || ($dir eq "")} {
-	    continue
-	}
-	set checked($dir) {}
-	foreach ext $execExtensions {
+    # KD : reversed the loops to match search order in [exec]
+    foreach ext $execExtensions {
+        unset -nocomplain checked
+        foreach dir [split $path {;}] {
+            # Skip already checked directories
+            if {[info exists checked($dir)] || ($dir eq "")} {
+                continue
+            }
+            set checked($dir) {}
 	    set file [file join $dir ${name}${ext}]
 	    if {[file exists $file] && ![file isdirectory $file]} {
 		return [set auto_execs($name) [list $file]]