1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
23 * tables for the test builin [[...]] and [...]
32 * This is the list of binary test and [[...]] operators
35 const Shtable_t shtab_testops
[] =
58 const char sh_opttest
[] =
59 "[-1c?\n@(#)$Id: test (AT&T Research) 2003-03-18 $\n]"
61 "[+NAME?test - evaluate expression]"
62 "[+DESCRIPTION?\btest\b evaluates expressions and indicates its "
63 "results based on the exit status. Option parsing is not "
64 "performed so that all arguments, including \b--\b are processed "
65 " as operands. The evaluation of the "
66 "expression depends on the number of operands as follows:]{"
67 "[+0?Evaluates to false.]"
68 "[+1?True if argument is not an empty string.]"
69 "[+2?If first operand is \b!\b, the result is True if the second "
70 "operand an empty string. Otherwise, it is evaluated "
71 "as one of the unary expressions defined below. If the "
72 "unary operator is invalid and the second argument is \b--\b,"
73 "then the first argument is processed as an option argument.]"
74 "[+3?If first operand is \b!\b, the result is True if the second "
75 "and third operand evaluated as a unary expression is False. "
76 "Otherwise, the three operands are evaluaged as one of the "
77 "binary expressions listed below.]"
78 "[+4?If first operand is \b!\b, the result is True if the next "
79 "three operands are a valid binary expression that is False.]"
81 "[If any \afile\a is of the form \b/dev/fd/\b\an\a, then file descriptor "
83 "[+?Unary expressions can be one of the following:]{"
84 "[+-a \afile\a?True if \afile\a exists, obsolete.]"
85 "[+-b \afile\a?True if \afile\a exists and is a block special file.]"
86 "[+-c \afile\a?True if \afile\a exists and is a character special "
88 "[+-d \afile\a?True if \afile\a exists and is a directory.]"
89 "[+-e \afile\a?True if \afile\a exists.]"
90 "[+-f \afile\a?True if \afile\a exists and is a regular file.]"
91 "[+-g \afile\a?True if \afile\a exists and has its set-group-id bit "
93 "[+-h \afile\a?True if \afile\a exists and is a symbolic link.]"
94 "[+-k \afile\a?True if \afile\a exists and has its sticky bit on.]"
96 "[+-l \afile\a?True if \afile\a exists and is a symbolic link.]"
98 "[+-n \astring\a?True if length of \astring\a is non-zero.]"
99 "[+-o \aoption\a?True if the shell option \aoption\a is enabled.]"
100 "[+-p \afile\a?True if \afile\a exists and is a pipe or fifo.]"
101 "[+-r \afile\a?True if \afile\a exists and is readable.]"
102 "[+-s \afile\a?True if \afile\a exists and has size > 0.]"
103 "[+-t \afildes\a?True if file descriptor number \afildes\a is "
104 "open and is associated with a terminal device.]"
105 "[+-u \afile\a?True if \afile\a exists and has its set-user-id bit "
107 "[+-v \avarname\a?True if \avarname\a is a valid variable name that is set.]"
108 "[+-w \afile\a?True if \afile\a exists and is writable.]"
109 "[+-x \afile\a?True if \afile\a exists and is executable. For a "
110 "directory it means that it can be searched.]"
111 "[+-z \astring\a?True if \astring\a is a zero length string.]"
112 "[+-G \afile\a?True if \afile\a exists and group is the effective "
113 "group id of the current process.]"
114 "[+-L \afile\a?True if \afile\a exists and is a symbolic link.]"
115 "[+-N \afile\a?True if \afile\a exists and has been modified since "
117 "[+-O \afile\a?True if \afile\a exists and owner is the effective "
118 "user id of the current process.]"
119 "[+-R \avarname\a?True if \avarname\a is a name reference.]"
120 "[+-S \afile\a?True if \afile\a exists and is a socket.]"
122 "[+-V \afile\a?True if \afile\a exists and is a version "
124 #endif /* SHOPT_FS_3D */
126 "[+?Binary expressions can be one of the following:]{"
127 "[+\astring1\a = \astring2\a?True if \astring1\a is equal to "
129 "[+\astring1\a == \astring2\a?True if \astring1\a is equal to "
131 "[+\astring1\a != \astring2\a?True if \astring1\a is not equal to "
133 "[+\anum1\a -eq \anum2\a?True if numerical value of \anum1\a is "
134 "equal to \anum2\a.]"
135 "[+\anum1\a -ne \anum2\a?True if numerical value of \anum1\a is not "
136 "equal to \anum2\a.]"
137 "[+\anum1\a -lt \anum2\a?True if numerical value of \anum1\a is less "
139 "[+\anum1\a -le \anum2\a?True if numerical value of \anum1\a is less "
140 "than or equal to \anum2\a.]"
141 "[+\anum1\a -gt \anum2\a?True if numerical value of \anum1\a is "
142 "greater than \anum2\a.]"
143 "[+\anum1\a -ge \anum2\a?True if numerical value of \anum1\a is "
144 "greater than or equal to \anum2\a.]"
145 "[+\afile1\a -nt \afile2\a?True if \afile1\a is newer than \afile2\a "
146 "or \afile2\a does not exist.]"
147 "[+\afile1\a -ot \afile2\a?True if \afile1\a is older than \afile2\a "
148 "or \afile2\a does not exist.]"
149 "[+\afile1\a -ef \afile2\a?True if \afile1\a is another name for "
150 "\afile2\a. This will be true if \afile1\a is a hard link "
151 "or a symbolic link to \afile2\a.]"
157 "[+0?Indicates that the specified expression is True.]"
158 "[+1?Indicates that the specified expression is False.]"
159 "[+>1?An error occurred.]"
162 "[+SEE ALSO?\blet\b(1), \bexpr\b(1)]"
165 const char test_opchars
[] = "HLNRSVOGCaeohrwxdcbfugkv"
170 const char e_argument
[] = "argument expected";
171 const char e_missing
[] = "%s missing";
172 const char e_badop
[] = "%s: unknown operator";
173 const char e_tstbegin
[] = "[[ ! ";
174 const char e_tstend
[] = " ]]\n";