📄 test.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>test</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="test"></a> <a name="tag_04_140"></a><!-- test --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_140_01"></a>NAME</h4><blockquote>test - evaluate expression</blockquote><h4><a name="tag_04_140_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>test</tt> <b>[</b><i>expression</i><b>]</b><tt><br><br>[</tt> <b>[</b><i>expression</i><b>]</b> <tt>]<br></tt></code></p></blockquote><h4><a name="tag_04_140_03"></a>DESCRIPTION</h4><blockquote><p>The <i>test</i> utility shall evaluate the <i>expression</i> and indicate the result of the evaluation by its exit status. Anexit status of zero indicates that the expression evaluated as true and an exit status of 1 indicates that the expression evaluatedas false.</p><p>In the second form of the utility, which uses <tt>"[]"</tt> rather than <i>test</i>, the application shall ensure that thesquare brackets are separate arguments.</p></blockquote><h4><a name="tag_04_140_04"></a>OPTIONS</h4><blockquote><p>The <i>test</i> utility shall not recognize the <tt>"--"</tt> argument in the manner specified by guideline 10 in the BaseDefinitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility SyntaxGuidelines</a>.</p><p>No options shall be supported.</p></blockquote><h4><a name="tag_04_140_05"></a>OPERANDS</h4><blockquote><p>The application shall ensure that all operators and elements of primaries are presented as separate arguments to the <i>test</i>utility.</p><p>The following primaries can be used to construct <i>expression</i>:</p><dl compact><dt><b>-b </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a block special file.</dd><dt><b>-c </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a character special file.</dd><dt><b>-d </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a directory.</dd><dt><b>-e </b> <i>file</i></dt><dd>True if <i>file</i> exists.</dd><dt><b>-f </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a regular file.</dd><dt><b>-g </b> <i>file</i></dt><dd>True if <i>file</i> exists and its set-group-ID flag is set.</dd><dt><b>-h </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a symbolic link.</dd><dt><b>-L </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a symbolic link.</dd><dt><b>-n </b> <i>string</i></dt><dd>True if the length of <i>string</i> is non-zero.</dd><dt><b>-p </b> <i>file</i></dt><dd>True if <i>file</i> is a FIFO.</dd><dt><b>-r </b> <i>file</i></dt><dd>True if <i>file</i> exists and is readable. True shall indicate that permission to read from <i>file</i> will be granted, asdefined in <a href="xcu_chap01.html#tag_01_07_01_04"><i>File Read, Write, and Creation</i></a> .</dd><dt><b>-S </b> <i>file</i></dt><dd>True if <i>file</i> exists and is a socket.</dd><dt><b>-s </b> <i>file</i></dt><dd>True if <i>file</i> exists and has a size greater than zero.</dd><dt><b>-t </b> <i>file_descriptor</i></dt><dd><br>True if the file whose file descriptor number is <i>file_descriptor</i> is open and is associated with a terminal.</dd><dt><b>-u </b> <i>file</i></dt><dd>True if <i>file</i> exists and its set-user-ID flag is set.</dd><dt><b>-w </b> <i>file</i></dt><dd>True if <i>file</i> exists and is writable. True shall indicate that permission to write from <i>file</i> will be granted, asdefined in <a href="xcu_chap01.html#tag_01_07_01_04"><i>File Read, Write, and Creation</i></a> .</dd><dt><b>-x </b> <i>file</i></dt><dd>True if <i>file</i> exists and is executable. True shall indicate that permission to execute <i>file</i> will be granted, asdefined in <a href="xcu_chap01.html#tag_01_07_01_04"><i>File Read, Write, and Creation</i></a> . If <i>file</i> is a directory,true shall indicate that permission to search <i>file</i> will be granted.</dd><dt><b>-z </b> <i>string</i></dt><dd>True if the length of string <i>string</i> is zero.</dd><dt><i>string</i></dt><dd>True if the string <i>string</i> is not the null string.</dd><dt><i>s1</i><b> = </b> <i>s2</i></dt><dd>True if the strings <i>s1</i> and <i>s2</i> are identical.</dd><dt><i>s1</i><b> != </b> <i>s2</i></dt><dd>True if the strings <i>s1</i> and <i>s2</i> are not identical.</dd><dt><i>n1</i><b> -eq </b> <i>n2</i></dt><dd>True if the integers <i>n1</i> and <i>n2</i> are algebraically equal.</dd><dt><i>n1</i><b> -ne </b> <i>n2</i></dt><dd>True if the integers <i>n1</i> and <i>n2</i> are not algebraically equal.</dd><dt><i>n1</i><b> -gt </b> <i>n2</i></dt><dd>True if the integer <i>n1</i> is algebraically greater than the integer <i>n2</i>.</dd><dt><i>n1</i><b> -ge </b> <i>n2</i></dt><dd>True if the integer <i>n1</i> is algebraically greater than or equal to the integer <i>n2</i>.</dd><dt><i>n1</i><b> -lt </b> <i>n2</i></dt><dd>True if the integer <i>n1</i> is algebraically less than the integer <i>n2</i>.</dd><dt><i>n1</i><b> -le </b> <i>n2</i></dt><dd>True if the integer <i>n1</i> is algebraically less than or equal to the integer <i>n2</i>.</dd><dt><i>expression1</i><b> -a </b> <i>expression2</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>True if both <i>expression1</i> and <i>expression2</i> are true. The <b>-a</b> binary primary is left associative. It has a higherprecedence than <b>-o</b>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><i>expression1</i><b> -o </b> <i>expression2</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"><br>True if either <i>expression1</i> or <i>expression2</i> is true. The <b>-o</b> binary primary is left associative. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>With the exception of the <b>-h</b> <i>file</i> and <b>-L</b> <i>file</i> primaries, if a <i>file</i> argument is a symboliclink, <i>test</i> shall evaluate the expression by resolving the symbolic link and using the file referenced by the link.</p><p>These primaries can be combined with the following operators:</p><dl compact><dt><b>! </b> <i>expression</i></dt><dd>True if <i>expression</i> is false.</dd><dt><b>( </b> <i>expression </i> <b>)</b></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">True if <i>expression</i> is true. The parentheses can be used to alter the normal precedence and associativity. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl><p>The primaries with two elements of the form:</p><pre><tt>-</tt><i>primary_operator primary_operand</i></pre><p>are known as <i>unary primaries</i>. The primaries with three elements in either of the two forms:</p><pre><i>primary_operand</i> <tt>-</tt><i>primary_operator primary_operand<br>primary_operand primary_operator primary_operand</i></pre><p>are known as <i>binary primaries</i>. Additional implementation-defined operators and <i>primary_operator</i>s may be providedby implementations. They shall be of the form - <i>operator</i> where the first character of <i>operator</i> is not a digit.</p><p>The algorithm for determining the precedence of the operators and the return value that shall be generated is based on thenumber of arguments presented to <i>test</i>. (However, when using the <tt>"[...]"</tt> form, the right-bracket final argumentshall not be counted in this algorithm.)</p><p>In the following list, $1, $2, $3, and $4 represent the arguments presented to <i>test</i>:</p><dl compact><dt>0 arguments:</dt><dd>Exit false (1).</dd><dt>1 argument:</dt><dd>Exit true (0) if $1 is not null; otherwise, exit false.</dd><dt>2 arguments:</dt><dd><ul><li><p>If $1 is <tt>'!'</tt> , exit true if $2 is null, false if $2 is not null.</p></li><li><p>If $1 is a unary primary, exit true if the unary test is true, false if the unary test is false.</p></li><li><p>Otherwise, produce unspecified results.</p></li></ul></dd><dt>3 arguments:</dt><dd><ul><li><p>If $2 is a binary primary, perform the binary test of $1 and $3.</p></li><li><p>If $1 is <tt>'!'</tt> , negate the two-argument test of $2 and $3.</p></li><li><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If $1 is <tt>'('</tt> and $3 is <tt>')'</tt> , perform the unary test of $2. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p></li><li><p>Otherwise, produce unspecified results.</p></li></ul></dd><dt>4 arguments:</dt><dd><ul><li><p>If $1 is <tt>'!'</tt> , negate the three-argument test of $2, $3, and $4.</p></li><li><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If $1 is <tt>'('</tt> and $4 is <tt>')'</tt> , perform the two-argument test of $2 and $3. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p>Otherwise, the results are unspecified.</p></li></ul></dd><dt>>4 arguments:</dt><dd>The results are unspecified. <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">On XSI-conformant systems, combinations of primaries and operators shall be evaluated using the precedence and associativity rulesdescribed previously. In addition, the string comparison binary primaries <tt>'='</tt> and <tt>"!="</tt> shall have a higherprecedence than any unary primary. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></dd></dl></blockquote><h4><a name="tag_04_140_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_140_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_140_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>test</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standarderror.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_140_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_140_10"></a>STDOUT</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_140_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_140_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_140_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_140_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd><i>expression</i> evaluated to true.</dd><dt> 1</dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -