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

📄 sh.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
📖 第 1 页 / 共 5 页
字号:
## !INSTALLSHELLPATH -p#scripts="a b c"## Transform each script#for i in ${scripts}do    sed -e "s|INSTALLSHELLPATH|${Pshell}|" &lt; ${i}.source &gt; ${i}done</tt></pre></blockquote><h4><a name="tag_04_128_17"></a>EXAMPLES</h4><blockquote><ol><li><p>Execute a shell command from a string:</p><pre><tt>sh -c "cat myfile"</tt></pre></li><li><p>Execute a shell script from a file in the current directory:</p><pre><tt>sh my_shell_cmds</tt></pre></li></ol></blockquote><h4><a name="tag_04_128_18"></a>RATIONALE</h4><blockquote><p>The <i>sh</i> utility and the <a href="../utilities/set.html"><i>set</i></a> special built-in utility share a commonset of options.</p><p>The KornShell ignores the contents of <i>IFS</i> upon entry to the script. A conforming application cannot rely on importing<i>IFS .</i> One justification for this, beyond security considerations, is to assist possible future shell compilers. Allowing<i>IFS</i> to be imported from the environment prevents many optimizations that might otherwise be performed via dataflow analysisof the script itself.</p><p>The text in the STDIN section about non-blocking reads concerns an instance of <i>sh</i> that has been invoked, probably by aC-language program, with standard input that has been opened using the O_NONBLOCK flag; see <a href="../functions/open.html"><i>open</i>()</a> in the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001. If the shell did notreset this flag, it would immediately terminate because no input data would be available yet and that would be considered the sameas end-of-file.</p><p>The options associated with a <i>restricted shell</i> (command name <i>rsh</i> and the <b>-r</b> option) were excluded becausethe standard developers considered that the implied level of security could not be achieved and they did not want to raise falseexpectations.</p><p>On systems that support set-user-ID scripts, a historical trapdoor has been to link a script to the name <b>-i</b>. When it iscalled by a sequence such as:</p><pre><tt>sh -</tt></pre><p>or by:</p><pre><tt>#! usr/bin/sh -</tt></pre><p>the historical systems have assumed that no option letters follow. Thus, this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 allowsthe single hyphen to mark the end of the options, in addition to the use of the regular <tt>"--"</tt> argument, because it wasconsidered that the older practice was so pervasive. An alternative approach is taken by the KornShell, where real and effectiveuser/group IDs must match for an interactive shell; this behavior is specifically allowed by this volume ofIEEE&nbsp;Std&nbsp;1003.1-2001. <basefont size="2"></p><dl><dt><b>Note:</b></dt><dd>There are other problems with set-user-ID scripts that the two approaches described here do not resolve.</dd></dl><basefont size="3"> <p>The initialization process for the history file can be dependent on the system start-up files, in that they may contain commandsthat effectively preempt the user's settings of <i>HISTFILE</i> and <i>HISTSIZE .</i> For example, function definition commands arerecorded in the history file, unless the <a href="../utilities/set.html"><i>set</i></a> <b>-o</b> <i>nolog</i> option isset. If the system administrator includes function definitions in some system start-up file called before the <i>ENV</i> file, thehistory file is initialized before the user gets a chance to influence its characteristics. In some historical shells, the historyfile is initialized just after the <i>ENV</i> file has been processed. Therefore, it is implementation-defined whether changes madeto <i>HISTFILE</i> after the history file has been initialized are effective.</p><p>The default messages for the various <i>MAIL -related</i> messages are unspecified because they vary across implementations.Typical messages are:</p><pre><tt>"you have mail\n"</tt></pre><p>or:</p><pre><tt>"you have new mail\n"</tt></pre><p>It is important that the descriptions of command line editing refer to the same shell as that in IEEE&nbsp;Std&nbsp;1003.1-2001so that interactive users can also be application programmers without having to deal with programmatic differences in their twoenvironments. It is also essential that the utility name <i>sh</i> be specified because this explicit utility name is too firmlyrooted in historical practice of application programs for it to change.</p><p>Consideration was given to mandating a diagnostic message when attempting to set <a href="../utilities/vi.html"><i>vi</i></a>-mode on terminals that do not support command line editing. However, it is not historicalpractice for the shell to be cognizant of all terminal types and thus be able to detect inappropriate terminals in all cases.Implementations are encouraged to supply diagnostics in this case whenever possible, rather than leaving the user in a state whereediting commands work incorrectly.</p><p>In early proposals, the KornShell-derived <i>emacs</i> mode of command line editing was included, even though the <i>emacs</i>editor itself was not. The community of <i>emacs</i> proponents was adamant that the full <i>emacs</i> editor not be standardizedbecause they were concerned that an attempt to standardize this very powerful environment would encourage vendors to ship strictlyconforming versions lacking the extensibility required by the community. The author of the original <i>emacs</i> program alsoexpressed his desire to omit the program. Furthermore, there were a number of historical systems that did not include <i>emacs</i>,or included it without supporting it, but there were very few that did not include and support <a href="../utilities/vi.html"><i>vi</i></a>. The shell <i>emacs</i> command line editing mode was finally omitted because it becameapparent that the KornShell version and the editor being distributed with the GNU system had diverged in some respects. The authorof <i>emacs</i> requested that the POSIX <i>emacs</i> mode either be deleted or have a significant number of unspecifiedconditions. Although the KornShell author agreed to consider changes to bring the shell into alignment, the standard developersdecided to defer specification at that time. At the time, it was assumed that convergence on an acceptable definition would occurfor a subsequent draft, but that has not happened, and there appears to be no impetus to do so. In any case, implementations arefree to offer additional command line editing modes based on the exact models of editors their users are most comfortable with.</p><p>Early proposals had the following list entry in <a href="#tag_04_128_13_04">vi Line Editing Insert Mode</a> :</p><dl compact><dt><tt>\</tt></dt><dd>If followed by the <i>erase</i> or <i>kill</i> character, that character shall be inserted into the input line. Otherwise, thebackslash itself shall be inserted into the input line.</dd></dl><p>However, this is not actually a feature of <i>sh</i> command line editing insert mode, but one of some historical terminal linedrivers. Some conforming implementations continue to do this when the <a href="../utilities/stty.html"><i>stty</i></a><b>iexten</b> flag is set.</p></blockquote><h4><a name="tag_04_128_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_128_20"></a>SEE ALSO</h4><blockquote><p><a href="xcu_chap02.html#tag_02"><i>Shell Command Language</i></a> , <a href="cd.html"><i>cd</i></a> , <a href="echo.html"><i>echo</i></a> , <a href="exit.html#tag_04_47"><i>exit</i>()</a> , <a href="fc.html"><i>fc</i></a> , <a href="pwd.html"><i>pwd</i></a> , <a href="read.html"><i>read</i>()</a> , <a href="set.html#tag_04_127"><i>set</i></a> , <a href="stty.html"><i>stty</i></a> , <a href="test.html"><i>test</i></a> , <a href="umask.html"><i>umask</i>()</a> , <a href="vi.html"><i>vi</i></a> , the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../functions/dup.html"><i>dup</i>()</a>, <i>exec</i>, <a href="../functions/exit.html"><i>exit</i>()</a>, <a href="../functions/fork.html"><i>fork</i>()</a>, <a href="../functions/open.html"><i>open</i>()</a>, <a href="../functions/pipe.html"><i>pipe</i>()</a>, <a href="../functions/signal.html"><i>signal</i>()</a>, <a href="../functions/system.html"><i>system</i>()</a>, <a href="../functions/ulimit.html"><i>ulimit</i>()</a>, <a href="../functions/umask.html"><i>umask</i>()</a>, <a href="../functions/wait.html"><i>wait</i>()</a></p></blockquote><h4><a name="tag_04_128_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_128_22"></a>Issue 5</h4><blockquote><p>The FUTURE DIRECTIONS section is added.</p><p>Text is added to the DESCRIPTION for the Large File Summit proposal.</p></blockquote><h4><a name="tag_04_128_23"></a>Issue 6</h4><blockquote><p>The Open Group Corrigendum U029/2 is applied, correcting the second SYNOPSIS.</p><p>The Open Group Corrigendum U027/3 is applied, correcting a typographical error.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The option letters derived from the <a href="../utilities/set.html"><i>set</i></a> special built-in are also acceptedwith a leading plus sign ( <tt>'+'</tt> ).</p></li><li><p>Large file extensions are added:</p><ul><li><p>Pathname expansion does not fail due to the size of a file.</p></li><li><p>Shell input and output redirections have an implementation-defined offset maximum that is established in the open filedescription.</p></li></ul></li></ul><p>In the ENVIRONMENT VARIABLES section, the text &quot;user's home directory&quot; is updated to &quot;directory referred to by the<i>HOME</i> environment variable&quot;.</p><p>Descriptions for the <i>ENV</i> and <i>PWD</i> environment variables are included to align with the IEEE&nbsp;P1003.2b draftstandard.</p><p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</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 + -