Tcl Source Code

Artifact [1e085a8ec2]
Login

Artifact 1e085a8ec26e59fc42a5f4c4a91222da833d6141:

Attachment "open.diff" to ticket [941380ffff] added by davidw 2004-04-24 23:37:04.
Index: open.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/open.n,v
retrieving revision 1.19
diff -u -r1.19 open.n
--- open.n	17 Mar 2004 18:14:12 -0000	1.19
+++ open.n	24 Apr 2004 16:08:56 -0000
@@ -132,6 +132,8 @@
 input unless overridden by the command.
 The id of the spawned process is accessible through the \fBpid\fR
 command, using the channel id returned by \fBopen\fR as argument.
+If the command executed in the command pipeline returns an error, a
+Tcl error is generated when \fBclose\fR is called on the channel.
 
 .VS 8.4
 .SH "SERIAL COMMUNICATIONS"
@@ -393,6 +395,18 @@
 See the PORTABILITY ISSUES section of the \fBexec\fR command for additional
 information not specific to command pipelines about executing
 applications on the various platforms
+
+.SH "EXAMPLE"
+
+Open a command pipeline and catch any errors:
+
+.CS
+set fl [open "| ls this_file_does_not_exist"]
+set data [read $fl]
+if { [catch { close $fl} err] } {
+    puts "ls command failed: $err"
+}
+.CE
 
 .SH "SEE ALSO"
 file(n), close(n), filename(n), fconfigure(n), gets(n), read(n),