summaryrefslogtreecommitdiffstats
path: root/doc/switch.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/switch.n')
-rw-r--r--doc/switch.n7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/switch.n b/doc/switch.n
index 21ecfc2..2f638de 100644
--- a/doc/switch.n
+++ b/doc/switch.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: switch.n,v 1.19 2008/06/29 22:28:24 dkf Exp $
+'\" RCS: @(#) $Id: switch.n,v 1.20 2008/10/17 10:22:25 dkf Exp $
'\"
.so man.macros
.TH switch n 8.5 Tcl "Tcl Built-In Commands"
@@ -124,8 +124,10 @@ Beware of how you place comments in \fBswitch\fR commands. Comments
should only be placed \fBinside\fR the execution body of one of the
patterns, and not intermingled with the patterns.
.SH "EXAMPLES"
+.PP
The \fBswitch\fR command can match against variables and not just
literals, as shown here (the result is \fI2\fR):
+.PP
.CS
set foo "abc"
\fBswitch\fR abc a \- b {expr {1}} $foo {expr {2}} default {expr {3}}
@@ -134,6 +136,7 @@ set foo "abc"
Using glob matching and the fall-through body is an alternative to
writing regular expressions with alternations, as can be seen here
(this returns \fI1\fR):
+.PP
.CS
\fBswitch\fR \-glob aaab {
a*b \-
@@ -145,6 +148,7 @@ writing regular expressions with alternations, as can be seen here
.PP
Whenever nothing matches, the \fBdefault\fR clause (which must be
last) is taken. This example has a result of \fI3\fR:
+.PP
.CS
\fBswitch\fR xyz {
a \-
@@ -163,6 +167,7 @@ last) is taken. This example has a result of \fI3\fR:
.PP
When matching against regular expressions, information about what
exactly matched is easily obtained using the \fB\-matchvar\fR option:
+.PP
.CS
\fBswitch\fR \-regexp \-matchvar foo \-\- $bar {
a(b*)c {