summaryrefslogtreecommitdiffstats
path: root/doc/exec.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:36:58 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:36:58 (GMT)
commitcd7e7ec95e76bcb5bf66d7cc9e6d60aad70dba07 (patch)
tree2f66883fc243d05145536a48036f61275d482016 /doc/exec.n
parentdfe0bb63c25ec4b9669b67071a6540448d5a7379 (diff)
downloadtcl-cd7e7ec95e76bcb5bf66d7cc9e6d60aad70dba07.zip
tcl-cd7e7ec95e76bcb5bf66d7cc9e6d60aad70dba07.tar.gz
tcl-cd7e7ec95e76bcb5bf66d7cc9e6d60aad70dba07.tar.bz2
Many minor doc fixes
Diffstat (limited to 'doc/exec.n')
-rw-r--r--doc/exec.n38
1 files changed, 19 insertions, 19 deletions
diff --git a/doc/exec.n b/doc/exec.n
index 62ff872..43893d8 100644
--- a/doc/exec.n
+++ b/doc/exec.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: exec.n,v 1.11 2004/08/31 15:19:36 dkf Exp $
+'\" RCS: @(#) $Id: exec.n,v 1.12 2004/10/27 09:36:58 dkf Exp $
'\"
.so man.macros
.TH exec n 8.5 Tcl "Tcl Built-In Commands"
@@ -330,18 +330,18 @@ The \fBexec\fR command is fully functional and works as described.
.SH "UNIX EXAMPLES"
Here are some examples of the use of the \fBexec\fR command on Unix.
-
+.PP
To execute a simple program and get its result:
.CS
-exec uname -a
+\fBexec\fR uname -a
.CE
-
+.PP
To execute a program that can return a non-zero result, you should
wrap the call to \fBexec\fR in \fBcatch\fR and check what the contents
of the global \fBerrorCode\fR variable is if you have an error:
.CS
set status 0
-if {[catch {exec grep foo bar.txt} results]} {
+if {[catch {\fBexec\fR grep foo bar.txt} results]} {
if {[lindex $::errorCode 0] eq "CHILDSTATUS"} {
set status [lindex $::errorCode 2]
} else {
@@ -349,7 +349,7 @@ if {[catch {exec grep foo bar.txt} results]} {
}
}
.CE
-
+.PP
When translating a command from a Unix shell invocation, care should
be taken over the fact that single quote characters have no special
significance to Tcl. Thus:
@@ -358,55 +358,55 @@ awk '{sum += $1} END {print sum}' numbers.list
.CE
would be translated into something like:
.CS
-exec awk {{sum += $1} END {print sum}} numbers.list
+\fBexec\fR awk {{sum += $1} END {print sum}} numbers.list
.CE
-
+.PP
If you are converting invocations involving shell globbing, you should
remember that Tcl does not handle globbing or expand things into
multiple arguments by default. Instead you should write things like
this:
.CS
-exec ls -l {expand}[glob *.tcl]
+\fBexec\fR ls -l {expand}[glob *.tcl]
.CE
-
+.PP
.SH "WINDOWS EXAMPLES"
Here are some examples of the use of the \fBexec\fR command on Windows.
-
+.PP
To start an instance of \fInotepad\fR editing a file without waiting
for the user to finish editing the file:
.CS
-exec notepad myfile.txt &
+\fBexec\fR notepad myfile.txt &
.CE
-
+.PP
To print a text file using \fInotepad\fR:
.CS
-exec notepad /p myfile.txt
+\fBexec\fR notepad /p myfile.txt
.CE
-
+.PP
If a program calls other programs, such as is common with compilers,
then you may need to resort to batch files to hide the console windows
that sometimes pop up:
.CS
-exec cmp.bat somefile.c -o somefile
+\fBexec\fR cmp.bat somefile.c -o somefile
.CE
With the file \fIcmp.bat\fR looking something like:
.CS
@gcc %1 %2 %3 %4 %5 %6 %7 %8 %9
.CE
-
+.PP
Sometimes you need to be careful, as different programs may have the
same name and be in the path. It can then happen that typing a command
at the DOS prompt finds \fIa different program\fR than the same
command run via \fBexec\fR. This is because of the (documented)
differences in behaviour between \fBexec\fR and DOS batch files.
-
+.PP
When in doubt, use the command \fBauto_execok\fR: it will return the
complete path to the program as seen by the \fBexec\fR command. This
applies especially when you want to run "internal" commands like
\fIdir\fR from a Tcl script (if you just want to list filenames, use
the \fBglob\fR command.) To do that, use this:
.CS
-exec {expand}[auto_execok dir] *.tcl
+\fBexec\fR {expand}[auto_execok dir] *.tcl
.CE
.SH "SEE ALSO"