Commit | Line | Data |
---|---|---|
41ec3b2b DR |
1 | .th IF I 3/15/72 |
2 | .sh NAME | |
3 | if \*- conditional command | |
4 | .sh SYNOPSIS | |
5 | .bd if | |
6 | expr command [ arg ... ] | |
7 | .sh DESCRIPTION | |
8 | .it If | |
9 | evaluates the expression | |
10 | .it expr, | |
11 | and if its value is | |
12 | true, | |
13 | executes the given | |
14 | .it command | |
15 | with the given arguments. | |
16 | .s3 | |
17 | The following primitives are used to construct | |
18 | the | |
19 | .it expr: | |
20 | .s3 | |
21 | .lp +10 10 | |
22 | \fB\*-r\fR|file true if the file exists and is readable. | |
23 | .s3 | |
24 | .lp +10 10 | |
25 | \fB\*-w|\fRfile true if the file exists and is writable | |
26 | .s3 | |
27 | .lp +10 10 | |
28 | s1|\fB=|\fRs2 true | |
29 | if the strings | |
30 | .it s1 | |
31 | and | |
32 | .it s2 | |
33 | are equal. | |
34 | .s3 | |
35 | .lp +10 10 | |
36 | s1|\fB!=|\fRs2 true | |
37 | if the strings | |
38 | .it s1 | |
39 | and | |
40 | .it s2 | |
41 | are not equal. | |
42 | .s3 | |
43 | .i0 | |
44 | These primaries may be combined with the | |
45 | following operators: | |
46 | .s3 | |
47 | .lp +10 10 | |
48 | \fB!\fR unary negation operator | |
49 | .s3 | |
50 | .lp +10 10 | |
51 | \fB\*-a\fR binary | |
52 | .it and | |
53 | operator | |
54 | .s3 | |
55 | .lp +10 10 | |
56 | \fB\*-o\fR binary | |
57 | .it or | |
58 | operator | |
59 | .s3 | |
60 | .lp +10 10 | |
61 | \fB(|\fRexpr\fB|)\fR parentheses for grouping. | |
62 | .s3 | |
63 | .i0 | |
64 | .bd \*-a | |
65 | has higher precedence than | |
66 | .bd \*-o. | |
67 | Notice that all the operators and flags are separate | |
68 | arguments to | |
69 | .it if | |
70 | and hence must be surrounded by spaces. | |
71 | Notice also that parentheses are meaningful | |
72 | to the Shell and must be escaped. | |
73 | .sh "SEE ALSO" | |
74 | sh(I) | |
75 | .sh BUGS |