1 # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
4 # Is there a canonical way of telling we are under CYGWIN?
5 global env tcl_platform maxima_priv
6 if {$tcl_platform(platform
) == "windows" && \
7 [info exists env
(PATH
)] && $env(PATH
) != "" && \
8 [string match
{*/usr
/bin
*} $env(PATH
)] && \
9 [string match
{*:*} $env(PATH
)] && \
10 ![string match
{*;*} $env(PATH
)]} {
11 # CYGWIN uses Unix PATH but Tcl considers it Windows
12 # What's even worse auto_execok uses ; but exec uses :
14 set env
(PATH
) [join [split $env(PATH
) ":"] ";"]
16 set maxima_priv
(platform
) cygwin
19 # Note that info executable doesn't work under Windows, so we have to
20 # look for files with .exe, .com, or .bat extensions. Also, the path
21 # may be in the Path or PATH environment variables, and path
22 # components are separated with semicolons, not colons as under Unix.
24 proc auto_execok name
{
25 global auto_execs env tcl_platform
27 if {[info exists auto_execs
($name)]} {
28 return $auto_execs($name)
30 set auto_execs
($name) ""
32 set shellBuiltins
[list cls copy date del erase dir echo mkdir
\
33 md
rename ren rmdir rd
time type ver vol
]
34 if {[string equal
$tcl_platform(os
) "Windows NT"]} {
35 # NT includes the 'start' built-in
36 lappend shellBuiltins
"start"
38 if {[info exists env
(PATHEXT
)]} {
39 # Add an initial : to have the {} extension check first.
40 set execExtensions
[split ":$env(PATHEXT)" ":"]
42 set execExtensions
[list {} .bat .com .exe
]
45 if {[lsearch -exact $shellBuiltins $name] != -1} {
46 return [set auto_execs
($name) [list $env(COMSPEC
) /c
$name]]
49 if {[llength [file split $name]] != 1} {
50 foreach ext
$execExtensions {
51 set file ${name
}${ext
}
52 if {[file exists
$file] && ![file isdirectory
$file]} {
53 return [set auto_execs
($name) [list $file]]
59 set path
"[file dirname [info nameof]]:.:"
60 if {[info exists env
(WINDIR
)]} {
61 set windir
$env(WINDIR
)
63 if {[info exists windir
]} {
64 if {[string equal
$tcl_platform(os
) "Windows NT"]} {
65 append path
"$windir/system32:"
67 append path
"$windir/system:$windir:"
70 foreach var
{PATH Path path
} {
71 if {[info exists env
($var)]} {
72 append path
":$env($var)"
77 foreach dir
[split $path {:}] {
78 # Skip already checked directories
79 if {[info exists checked
($dir)] ||
[string equal
{} $dir]} { continue }
81 foreach ext
$execExtensions {
82 set file [file join $dir ${name
}${ext
}]
83 if {[file exists
$file] && ![file isdirectory
$file]} {
84 return [set auto_execs
($name) [list $file]]
94 set maxima_priv
(platform
) $tcl_platform(platform
)