Skip to content

Commit 81aaf0f

Browse files
Tcl 9 portability, file home
1 parent e2f811a commit 81aaf0f

File tree

4 files changed

+10
-23
lines changed

4 files changed

+10
-23
lines changed

examples/httpd/httpd.tcl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set DEMOROOT [file join $DIR htdocs]
77
set tcllibroot [file normalize [file join $DIR .. ..]]
88
set auto_path [linsert $auto_path 0 [file normalize [file join $tcllibroot modules]]]
99
package require httpd 4.1
10+
package require file::home ;# tcllib file home forward compatibility
1011
###
1112
# This script creates two toplevel domains:
1213
# * Hosting the tcllib embedded documentation as static content
@@ -84,7 +85,7 @@ clay::define httpd::content.fossil_node_scgi {
8485
set prefix [my clay get prefix]
8586
set module [lindex [split $uri /] 2]
8687
if {[package vsatisfies [package present Tcl] 9]} {
87-
file mkdir [file tildeexpand ~/tmp]
88+
file mkdir [file join [file home] tmp]
8889
} else {
8990
file mkdir ~/tmp
9091
}
@@ -102,11 +103,7 @@ clay::define httpd::content.fossil_node_scgi {
102103
tailcall my error 400 {Not Found}
103104
}
104105
set mport [my <server> port_listening]
105-
if {[package vsatisfies [package present Tcl] 9]} {
106-
set cmd [list [::fossil] server $dbfile --port $port --localhost --scgi 2>[file home]/tmp/$module.err >[file home]/tmp/$module.log]
107-
} else {
108-
set cmd [list [::fossil] server $dbfile --port $port --localhost --scgi 2>~/tmp/$module.err >~/tmp/$module.log]
109-
}
106+
set cmd [list [::fossil] server $dbfile --port $port --localhost --scgi 2>[file home]/tmp/$module.err >[file home]/tmp/$module.log]
110107
dict set ::fossil_process($module) port $port
111108
dict set ::fossil_process($module) handle $handle
112109
dict set ::fossil_process($module) cmd $cmd

examples/mime/mbot/impersonal.tcl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88

99
package require Tcl 8.5 9
10+
package require file::home ;# tcllib file home forward compatibility
1011
global options
1112

1213

@@ -162,11 +163,7 @@ if {[catch {
162163
if {[catch { id convert user $userName }]} {
163164
cleanup "userName doesn't exist: $userName"
164165
}
165-
if {[package vsatisfies [package present Tcl] 9]} {
166-
set thisDir [file home $userName]
167-
} else {
168-
set thisDir ~$userName
169-
}
166+
set thisDir [file home $userName]
170167
if {([catch { file isdirectory $thisDir } result]) \
171168
|| (!$result)} {
172169
cleanup "userName doesn't have a home directory: $userName"

examples/mime/mbot/personal.tcl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010

1111
package require Tcl 8.5 9
12+
package require file::home ;# tcllib file home forward compatibility
1213

1314
global options
1415

@@ -466,11 +467,7 @@ if {[catch {
466467
if {[catch { id convert user $userName }]} {
467468
cleanup "userName doesn't exist: $userName"
468469
}
469-
if {[package vsatisfies [package present Tcl] 9]} {
470-
set thisDir [file home $userName]
471-
} else {
472-
set thisDir ~$userName
473-
}
470+
set thisDir [file home $userName]
474471
if {([catch { file isdirectory $thisDir } result]) \
475472
|| (!$result)} {
476473
cleanup "userName doesn't have a home directory: $userName"

support/devel/sak/util/registry.tcl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
##
44
# ###
55

6-
getpackage pregistry registry/registry.tcl
6+
getpackage pregistry registry/registry.tcl
7+
getpackage file::home try/fhome.tcl ;# file home forward compatibility
78

89
namespace eval ::sak::registry {}
910

@@ -39,12 +40,7 @@ proc ::sak::registry::Refresh {} {
3940

4041
namespace eval ::sak::registry {
4142
variable _here [file dirname [info script]]
42-
43-
if {[package vsatisfies [package present Tcl] 9]} {
44-
variable statedir [file join [file home] .Tcllib]
45-
} else {
46-
variable statedir [file join ~ .Tcllib]
47-
}
43+
variable statedir [file join [file home] .Tcllib]
4844
variable state [file join $statedir Registry]
4945
variable _local {}
5046
}

0 commit comments

Comments
 (0)