Thu Oct 1 21:40:31 2009 UTC ()
Add example of how to use the ?: modifier properly.


(dsl)
diff -r1.161 -r1.162 src/usr.bin/make/make.1

cvs diff -r1.161 -r1.162 src/usr.bin/make/make.1 (expand / switch to unified diff)

--- src/usr.bin/make/make.1 2009/09/08 17:29:20 1.161
+++ src/usr.bin/make/make.1 2009/10/01 21:40:31 1.162
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: make.1,v 1.161 2009/09/08 17:29:20 sjg Exp $ 1.\" $NetBSD: make.1,v 1.162 2009/10/01 21:40:31 dsl Exp $
2.\" 2.\"
3.\" Copyright (c) 1990, 1993 3.\" Copyright (c) 1990, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE. 28.\" SUCH DAMAGE.
29.\" 29.\"
30.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 30.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
31.\" 31.\"
32.Dd September 7, 2009 32.Dd October 1, 2009
33.Dt MAKE 1 33.Dt MAKE 1
34.Os 34.Os
35.Sh NAME 35.Sh NAME
36.Nm make 36.Nm make
37.Nd maintain program dependencies 37.Nd maintain program dependencies
38.Sh SYNOPSIS 38.Sh SYNOPSIS
39.Nm 39.Nm
40.Op Fl BeikNnqrstWX 40.Op Fl BeikNnqrstWX
41.Bk -words 41.Bk -words
42.Op Fl C Ar directory 42.Op Fl C Ar directory
43.Ek 43.Ek
44.Bk -words 44.Bk -words
45.Op Fl D Ar variable 45.Op Fl D Ar variable
@@ -1051,28 +1051,31 @@ Replaces each word in the variable with  @@ -1051,28 +1051,31 @@ Replaces each word in the variable with
1051Remove adjacent duplicate words (like 1051Remove adjacent duplicate words (like
1052.Xr uniq 1 ) . 1052.Xr uniq 1 ) .
1053.Sm off 1053.Sm off
1054.It Cm \&:\&? Ar true_string Cm \&: Ar false_string 1054.It Cm \&:\&? Ar true_string Cm \&: Ar false_string
1055.Sm on 1055.Sm on
1056If the variable name (not its value), when parsed as a .if conditional 1056If the variable name (not its value), when parsed as a .if conditional
1057expression, evaluates to true, return as its value the 1057expression, evaluates to true, return as its value the
1058.Ar true_string , 1058.Ar true_string ,
1059otherwise return the 1059otherwise return the
1060.Ar false_string . 1060.Ar false_string .
1061Since the variable name is used as the expression, \&:\&? must be the 1061Since the variable name is used as the expression, \&:\&? must be the
1062first modifier after the variable name itself - which will, of course, 1062first modifier after the variable name itself - which will, of course,
1063usually contain variable expansions. 1063usually contain variable expansions.
1064If the expression is a single token, it will likely be treated as a check 1064A common error is trying to use expressions like
1065for the name being defined. 1065.Dl ${NUMBERS:M42:?match:no}
 1066which actually tests defined(NUMBERS),
 1067to determine is any words match "42" you need to use something like:
 1068.Dl ${${NUMBERS:M42} != "":?match:no} .
1066.It Ar :old_string=new_string 1069.It Ar :old_string=new_string
1067This is the 1070This is the
1068.At V 1071.At V
1069style variable substitution. 1072style variable substitution.
1070It must be the last modifier specified. 1073It must be the last modifier specified.
1071If 1074If
1072.Ar old_string 1075.Ar old_string
1073or 1076or
1074.Ar new_string 1077.Ar new_string
1075do not contain the pattern matching character 1078do not contain the pattern matching character
1076.Ar % 1079.Ar %
1077then it is assumed that they are 1080then it is assumed that they are
1078anchored at the end of each word, so only suffixes or entire 1081anchored at the end of each word, so only suffixes or entire