Jim Tcl
Check-in [92e4698aad]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:tclcompat.tcl: minor comment updates

Signed-off-by: Steve Bennett <steveb@workware.net.au>

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92e4698aadec2bc613c083d4d1814073613c402c
User & Date: steveb@workware.net.au 2017-11-07 21:47:35
Context
2017-11-07
21:48
docs: Bring README.utf-8 up-to-date

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 18ba56fba7 user: steveb@workware.net.au tags: trunk

21:47
tclcompat.tcl: minor comment updates

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: 92e4698aad user: steveb@workware.net.au tags: trunk

2017-11-04
09:16
interp: command should be created in the global namespace

Signed-off-by: Steve Bennett <steveb@workware.net.au> check-in: c6eab746a7 user: steveb@workware.net.au tags: trunk

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tclcompat.tcl.

1
2
3
4
5
6
7
8
9
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
182
183
184
185
186
187
188

189
190
191
192
193
194
195
# Loads some Tcl-compatible features.
# I/O commands, case, lassign, parray, errorInfo, ::tcl_platform, ::env
# try, throw, file copy, file delete -force
#
# (c) 2008 Steve Bennett <steveb@workware.net.au>


# Set up the ::env array
set env [env]
................................................................................
		return {*}$opts $msg
	} finally {
		catch {$in close}
	}
}

# 'open "|..." ?mode?" will invoke this wrapper around exec/pipe
# Note that we return a lambda which also provides the 'pid' command
proc popen {cmd {mode r}} {
	lassign [pipe] r w
	try {
		if {[string match "w*" $mode]} {
			lappend cmd <@$r &
			set pids [exec {*}$cmd]
			$r close
................................................................................
	} on error {error opts} {
		$r close
		$w close
		error $error
	}
}

# A wrapper around 'pid' which can return the pids for 'popen'
local proc pid {{channelId {}}} {
	if {$channelId eq ""} {
		tailcall upcall pid
	}
	if {[catch {$channelId tell}]} {
		return -code error "can not find channel named \"$channelId\""
	}
................................................................................
}

# try/on/finally conceptually similar to Tcl 8.6
#
# Usage: try ?catchopts? script ?onclause ...? ?finallyclause?
#
# Where:

#        onclause is: on codes {?resultvar? ?optsvar?} script
#           codes is: a list of return codes (ok, error, etc. or integers), or * for any
#   finallyclause is: finally script
proc try {args} {
	set catchopts {}
	while {[string match -* [lindex $args 0]]} {
		set args [lassign $args opt]

|







 







|







 







|







 







>







1
2
3
4
5
6
7
8
9
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Loads some Tcl-compatible features.
# I/O commands, parray, open |..., errorInfo, ::env
# try, throw, file copy, file delete -force
#
# (c) 2008 Steve Bennett <steveb@workware.net.au>


# Set up the ::env array
set env [env]
................................................................................
		return {*}$opts $msg
	} finally {
		catch {$in close}
	}
}

# 'open "|..." ?mode?" will invoke this wrapper around exec/pipe
# Note that we return a lambda that also provides the 'pid' command
proc popen {cmd {mode r}} {
	lassign [pipe] r w
	try {
		if {[string match "w*" $mode]} {
			lappend cmd <@$r &
			set pids [exec {*}$cmd]
			$r close
................................................................................
	} on error {error opts} {
		$r close
		$w close
		error $error
	}
}

# A wrapper around 'pid' that can return the pids for 'popen'
local proc pid {{channelId {}}} {
	if {$channelId eq ""} {
		tailcall upcall pid
	}
	if {[catch {$channelId tell}]} {
		return -code error "can not find channel named \"$channelId\""
	}
................................................................................
}

# try/on/finally conceptually similar to Tcl 8.6
#
# Usage: try ?catchopts? script ?onclause ...? ?finallyclause?
#
# Where:
#       catchopts is: options for catch such as -nobreak, -signal
#        onclause is: on codes {?resultvar? ?optsvar?} script
#           codes is: a list of return codes (ok, error, etc. or integers), or * for any
#   finallyclause is: finally script
proc try {args} {
	set catchopts {}
	while {[string match -* [lindex $args 0]]} {
		set args [lassign $args opt]