Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): prettify .for index variable example
details: https://anonhg.NetBSD.org/src/rev/6a0c8817aef7
branches: trunk
changeset: 368969:6a0c8817aef7
user: uwe <uwe%NetBSD.org@localhost>
date: Sun Aug 14 21:53:58 2022 +0000
description:
make(1): prettify .for index variable example
diffstat:
usr.bin/make/make.1 | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diffs (65 lines):
diff -r 40689d111e6f -r 6a0c8817aef7 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Sun Aug 14 21:48:05 2022 +0000
+++ b/usr.bin/make/make.1 Sun Aug 14 21:53:58 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.327 2022/08/14 21:48:05 uwe Exp $
+.\" $NetBSD: make.1,v 1.328 2022/08/14 21:53:58 uwe Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -674,38 +674,42 @@
Variables in shell commands are expanded when the shell command is
executed.
.It
-.Dq .for
+.Ic .for
loop index variables are expanded on each loop iteration.
Note that other variables are not expanded when composing the body of a loop,
so the following example code:
.Bd -literal -offset indent
-
-.Dv .for i in 1 2 3
+\&.for i in 1 2 3
a+= ${i}
j= ${i}
b+= ${j}
-.Dv .endfor
+\&.endfor
all:
@echo ${a}
@echo ${b}
-
.Ed
+.Pp
will print:
.Bd -literal -offset indent
1 2 3
3 3 3
-
.Ed
-Because while ${a} contains
-.Dq 1 2 3
-after the loop is executed, ${b}
+.Pp
+Because while
+.Va a
contains
-.Dq ${j} ${j} ${j}
+.Ql 1 2 3
+after the loop is executed,
+.Va b
+contains
+.Ql ${j} ${j} ${j}
which expands to
-.Dq 3 3 3
-since after the loop completes ${j} contains
-.Dq 3 .
+.Ql 3 3 3
+since after the loop completes
+.Va j
+contains
+.Ql 3 .
.El
.Ss Variable classes
The four different classes of variables (in order of increasing precedence)
Home |
Main Index |
Thread Index |
Old Index