Commit | Line | Data |
---|---|---|
3cc4e5af DR |
1 | .pa 1 |
2 | .he 'IF (I)'3/15/72'IF (I)' | |
3 | .ti 0 | |
4 | NAME if -- conditional command | |
5 | .sp | |
6 | .ti 0 | |
7 | SYNOPSIS if\b\b__ expr command [ arg\e91\e8 ... ] | |
8 | .sp | |
9 | .ti 0 | |
10 | DESCRIPTION if\b\b__ | |
11 | evaluates the expression expr\b\b\b\b____, and if its value is true\b\b\b\b____, | |
12 | executes the given command\b\b\b\b\b\b\b_______ with the given arguments. | |
13 | ||
14 | The following primitives are used to construct | |
15 | the expr\b\b\b\b____: | |
16 | ||
17 | .in +9 | |
18 | .ti -4 | |
19 | -r\b\b__ file | |
20 | .br | |
21 | true if the file exists and is readable. | |
22 | ||
23 | .ti -4 | |
24 | -w\b\b__ file | |
25 | .br | |
26 | true if the file exists and is writable | |
27 | ||
28 | .ti -4 | |
29 | s1 =\b_ s2 | |
30 | .br | |
31 | true if the strings s1\b\b__ and s2\b\b__ are equal. | |
32 | ||
33 | .ti -4 | |
34 | s1 !=\b\b__ s2 | |
35 | .br | |
36 | true if the strings s1\b\b__ and s2\b\b__ are not equal. | |
37 | ||
38 | .in -9 | |
39 | These primaries may be combined with the | |
40 | following operators: | |
41 | ||
42 | .in +5 | |
43 | !\b_ | |
44 | .ti +4 | |
45 | unary negation operator | |
46 | ||
47 | -a\b\b__ | |
48 | .ti +4 | |
49 | binary and\b\b\b___ operator | |
50 | ||
51 | -o\b\b__ | |
52 | .ti +4 | |
53 | binary or\b\b__ operator | |
54 | ||
55 | (\b_ expr )\b_ | |
56 | .ti +4 | |
57 | parentheses for grouping. | |
58 | ||
59 | .in -5 | |
60 | -a\b\b__ has higher precedence than -o\b\b__. | |
61 | Notice that all the operators and flags are separate | |
62 | arguments to if\b\b__ and hence must be surrounded by spaces. | |
63 | .sp | |
64 | .ti 0 | |
65 | FILES -- | |
66 | .sp | |
67 | .ti 0 | |
68 | SEE ALSO sh(I) | |
69 | .sp | |
70 | .ti 0 | |
71 | DIAGNOSTICS "if error", | |
72 | if the expression has the wrong syntax; | |
73 | "command not found." | |
74 | .sp | |
75 | .ti 0 | |
76 | BUGS -- |