summaryrefslogtreecommitdiffstats
path: root/doc/subst.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/subst.n')
-rw-r--r--doc/subst.n25
1 files changed, 22 insertions, 3 deletions
diff --git a/doc/subst.n b/doc/subst.n
index 07f0933..4518140 100644
--- a/doc/subst.n
+++ b/doc/subst.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.
-'\"
+'\"
.TH subst n 7.4 Tcl "Tcl Built-In Commands"
.so man.macros
.BS
@@ -33,7 +33,7 @@ For example, if \fB\-nocommands\fR is specified, command substitution
is not performed: open and close brackets are treated as ordinary characters
with no special interpretation.
.PP
-Note that the substitution of one kind can include substitution of
+Note that the substitution of one kind can include substitution of
other kinds. For example, even when the \fB\-novariables\fR option
is specified, command substitution is performed without restriction.
This means that any variable substitution necessary to complete the
@@ -62,19 +62,23 @@ itself will either return an error, or will complete successfully.
When it performs its substitutions, \fIsubst\fR does not give any
special treatment to double quotes or curly braces (except within
command substitutions) so the script
+.PP
.CS
set a 44
\fBsubst\fR {xyz {$a}}
.CE
+.PP
returns
.QW "\fBxyz {44}\fR" ,
not
.QW "\fBxyz {$a}\fR"
and the script
+.PP
.CS
set a "p\e} q \e{r"
\fBsubst\fR {xyz {$a}}
.CE
+.PP
returns
.QW "\fBxyz {p} q {r}\fR" ,
not
@@ -82,10 +86,12 @@ not
.PP
When command substitution is performed, it includes any variable
substitution necessary to evaluate the script.
+.PP
.CS
set a 44
\fBsubst\fR -novariables {$a [format $a]}
.CE
+.PP
returns
.QW "\fB$a 44\fR" ,
not
@@ -93,11 +99,13 @@ not
Similarly, when
variable substitution is performed, it includes any command
substitution necessary to retrieve the value of the variable.
+.PP
.CS
proc b {} {return c}
array set a {c c [b] tricky}
\fBsubst\fR -nocommands {[b] $a([b])}
.CE
+.PP
returns
.QW "\fB[b] c\fR" ,
not
@@ -107,34 +115,42 @@ The continue and break exceptions allow command substitutions to
prevent substitution of the rest of the command substitution and the
rest of \fIstring\fR respectively, giving script authors more options
when processing text using \fIsubst\fR. For example, the script
+.PP
.CS
\fBsubst\fR {abc,[break],def}
.CE
+.PP
returns
.QW \fBabc,\fR ,
not
.QW \fBabc,,def\fR
and the script
+.PP
.CS
\fBsubst\fR {abc,[continue;expr {1+2}],def}
.CE
+.PP
returns
.QW \fBabc,,def\fR ,
not
.QW \fBabc,3,def\fR .
.PP
Other exceptional return codes substitute the returned value
+.PP
.CS
\fBsubst\fR {abc,[return foo;expr {1+2}],def}
.CE
+.PP
returns
.QW \fBabc,foo,def\fR ,
not
.QW \fBabc,3,def\fR
and
+.PP
.CS
\fBsubst\fR {abc,[return -code 10 foo;expr {1+2}],def}
.CE
+.PP
also returns
.QW \fBabc,foo,def\fR ,
not
@@ -142,4 +158,7 @@ not
.SH "SEE ALSO"
Tcl(n), eval(n), break(n), continue(n)
.SH KEYWORDS
-backslash substitution, command substitution, variable substitution
+backslash substitution, command substitution, quoting, substitution, variable substitution
+.\" Local Variables:
+.\" mode: nroff
+.\" End: