⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exec.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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>exec</title></head><body bgcolor="white"><basefont size="3"> <a name="exec"></a> <a name="tag_04_46"></a><!-- exec --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_46_01"></a>NAME</h4><blockquote>exec - execute commands and open, close, or copy file descriptors</blockquote><h4><a name="tag_04_46_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>exec</tt> <b>[</b><i>command</i> <b>[</b><i>argument</i> <tt>...</tt><b>]]</b></code></p></blockquote><h4><a name="tag_04_46_03"></a>DESCRIPTION</h4><blockquote><p>The <i>exec</i> utility shall open, close, and/or copy file descriptors as specified by any redirections as part of thecommand.</p><p>If <i>exec</i> is specified without <i>command</i> or <i>argument</i>s, and any file descriptors with numbers greater than 2 areopened with associated redirection statements, it is unspecified whether those file descriptors remain open when the shell invokesanother utility. Scripts concerned that child shells could misuse open file descriptors can always close them explicitly, as shownin one of the following examples.</p><p>If <i>exec</i> is specified with <i>command</i>, it shall replace the shell with <i>command</i> without creating a new process.If <i>argument</i>s are specified, they shall be arguments to <i>command</i>. Redirection affects the current shell executionenvironment.</p></blockquote><h4><a name="tag_04_46_04"></a>OPTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_05"></a>OPERANDS</h4><blockquote><p>See the DESCRIPTION.</p></blockquote><h4><a name="tag_04_46_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_46_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_46_10"></a>STDOUT</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_46_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_46_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_14"></a>EXIT STATUS</h4><blockquote><p>If <i>command</i> is specified, <i>exec</i> shall not return to the shell; rather, the exit status of the process shall be theexit status of the program implementing <i>command</i>, which overlaid the shell. If <i>command</i> is not found, the exit statusshall be 127. If <i>command</i> is found, but it is not an executable utility, the exit status shall be 126. If a redirection erroroccurs (see <a href="xcu_chap02.html#tag_02_08_01"><i>Consequences of Shell Errors</i></a> ), the shell shall exit with a value inthe range 1-125. Otherwise, <i>exec</i> shall return a zero exit status.</p></blockquote><h4><a name="tag_04_46_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_46_16"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_17"></a>EXAMPLES</h4><blockquote><p>Open <i>readfile</i> as file descriptor 3 for reading:</p><pre><tt>exec 3&lt; readfile</tt></pre><p>Open <i>writefile</i> as file descriptor 4 for writing:</p><pre><tt>exec 4&gt; writefile</tt></pre><p>Make file descriptor 5 a copy of file descriptor 0:</p><pre><tt>exec 5&lt;&amp;0</tt></pre><p>Close file descriptor 3:</p><pre><tt>exec 3&lt;&amp;-</tt></pre><p>Cat the file <b>maggie</b> by replacing the current shell with the <a href="../utilities/cat.html"><i>cat</i></a> utility:</p><pre><tt>exec cat maggie</tt></pre></blockquote><h4><a name="tag_04_46_18"></a>RATIONALE</h4><blockquote><p>Most historical implementations were not conformant in that:</p><pre><tt>foo=bar exec cmd</tt></pre><p>did not pass <b>foo</b> to <b>cmd</b>.</p></blockquote><h4><a name="tag_04_46_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_46_20"></a>SEE ALSO</h4><blockquote><p><a href="xcu_chap02.html#tag_02_14"><i>Special Built-In Utilities</i></a></p></blockquote><h4><a name="tag_04_46_21"></a>CHANGE HISTORY</h4><h4><a name="tag_04_46_22"></a>Issue 6</h4><blockquote><p>IEEE&nbsp;Std 1003.1-2001/Cor&nbsp;1-2002, item XCU/TC1/D6/5 is applied so that the reference page sections use terms asdescribed in the Utility Description Defaults ( <a href="xcu_chap01.html#tag_01_11"><i>Utility Description Defaults</i></a> ). Nochange in behavior is intended.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -