?? _chapter 10.htm
字號:
<a class="docLink" href="#ch10table01">Table 10.1</a>).</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">Unsets the <span class="docEmphasis">allexport</span>
option. Same as 2.</span></li>
</ol>
</span></td>
</tr>
</table>
<p> </p>
<table cellSpacing="0" cellPadding="1" width="100%" border="1">
<caption>
<h5 id="ch10table01" class="docTableTitle">Table 10.1. Options</h5>
</caption>
<colgroup span="3" align="left">
</colgroup>
<tr>
<th class="docTableHeader" vAlign="top"><span class="docEmphBoldItalic">Name
of Option</span> </th>
<th class="docTableHeader" vAlign="top"><span class="docEmphBoldItalic">
Abbreviation</span> </th>
<th class="docTableHeader" vAlign="top"><span class="docEmphBoldItalic">What
It Does</span> </th>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">allexport</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">朼</span>
</td>
<td class="docTableCell" vAlign="top">Causes variables set to be
automatically exported. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">bgnice</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Background jobs are run with a lower
priority. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">emacs</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">For command line editing, uses the
<span class="docEmphasis">emacs</span> built-in editor. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">errexit</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杄</span>
</td>
<td class="docTableCell" vAlign="top">If a command returns a nonzero exit
status (fails), executes the <span class="docEmphasis">ERR</span> trap, if
set, and exits. Not set when reading initialization files. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">gmacs</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">For command editing, uses the
<span class="docEmphasis">gmacs</span> built-in editor. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">ignoreeof</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Prevents logout with ^D; must type
<span class="docEmphasis">exit</span> to exit the shell. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">markdirs</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Puts a trailing backslash (/) on
directory names when filename expansion is used. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">monitor</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杕</span>
</td>
<td class="docTableCell" vAlign="top">Allows job control. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">noclobber</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Protects files from being overwritten
when redirection is used. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">noexec</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杗</span>
</td>
<td class="docTableCell" vAlign="top">Reads commands, but does not execute
them. Used to check the syntax of scripts. Not on when running
interactively. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">noglob</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杅</span>
</td>
<td class="docTableCell" vAlign="top">Disables pathname expansion; i.e.,
turns off wildcards. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">nolog</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Does not store function definitions in
the history file. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">notify</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Notifies user when background job
finishes (only in versions newer than 1988). </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">nounset</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Displays an error when expanding a
variable that has not been set. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">privileged</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杙</span>
</td>
<td class="docTableCell" vAlign="top">When set, the shell does not read the
<span class="docEmphasis">.profile</span> or <span class="docEmphasis">ENV</span>
file; used with <span class="docEmphasis">setuid</span> scripts. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">trackall</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">Enables alias tracking. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">verbose</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杤</span>
</td>
<td class="docTableCell" vAlign="top">Turns on the <span class="docEmphasis">
verbose</span> mode for debugging. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">vi</span>
</td>
<td class="docTableCell" vAlign="top"> </td>
<td class="docTableCell" vAlign="top">For command line editing, uses the
<span class="docEmphasis">vi</span> built-in editor. </td>
</tr>
<tr>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">xtrace</span>
</td>
<td class="docTableCell" vAlign="top"><span class="docEmphasis">杧</span>
</td>
<td class="docTableCell" vAlign="top">Turns on the echo mode for debugging.
</td>
</tr>
</table>
<h4 class="docSection2Title" id="ch10lev2sec3">10.1.3 The Prompts</h4>
<p class="docText">The Korn shell provides four prompts.The primary and
secondary prompts are used when the Korn shell is running interactively. You can
change these prompts. The variable <span class="docEmphasis">PS1</span> is the
primary prompt, set initially to a dollar sign (<span class="docEmphasis">$</span>).
It appears when you log on and waits for you to type commands. The variable
<span class="docEmphasis">PS2</span> is the secondary prompt, initially set to
the > character. It appears if you have partially typed a command and then
pressed Enter. You can change the primary and secondary prompts.</p>
<p class="docText"><b>The Primary Prompt.</b> <span class="docEmphasis">$</span>
is the default primary prompt. You can change your prompt. Normally, prompts are
defined in <span class="docEmphasis">.profile.</span></p>
<h5 id="ch10list04" class="docExampleTitle">Example 10.4 </h5>
<pre>1 $ <span class="docEmphStrong">PS1="$(uname 杗) ! $ "</span>
2 <span class="docEmphasis">jody 1141 $</span>
</pre>
<table cellSpacing="0" width="90%" border="1" align="center">
<tr>
<td>
<h2 class="docSidebarTitle">EXPLANATION</h2>
<span style="FONT-WEIGHT: bold">
<ol class="docList" type="1">
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The default primary prompt is a
<span class="docEmphasis">$.</span> The <span class="docEmphasis">PS1</span>
prompt is being reset to the name of the machine <span class="docEmphasis">
$(uname 杗</span>), the number of the current history number, and the
<span class="docEmphasis">$.</span> The exclamation point evaluates to the
current history number. (To print an exclamation point, type two
exclamation points (<span class="docEmphasis">!!</span>) in the
<span class="docEmphasis">PS1</span> definition.)</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The new prompt is displayed.</span></li>
</ol>
</span></td>
</tr>
</table>
<p class="docText"><b>The Secondary Prompt.</b> The <span class="docEmphasis">
PS2</span> prompt is the secondary prompt. Its value is displayed to standard
error (the screen). This prompt appears when you have not completed a command
and have pressed the carriage return.</p>
<h5 id="ch10list05" class="docExampleTitle">Example 10.5 </h5>
<pre>1 $ print "Hello
2 > there"
3 <span class="docEmphasis">Hello</span>
<span class="docEmphasis">there</span>
4 $
5 $ <span class="docEmphStrong">PS2="枛枛> "</span>
6 $ <span class="docEmphStrong">print "Hi</span>
7 <span class="docEmphStrong">枛枛枛></span>
<span class="docEmphStrong">枛枛枛></span>
<span class="docEmphStrong">枛枛枛> there"</span>
<span class="docEmphasis">Hi</span>
<span class="docEmphasis">there</span>
$
</pre>
<table cellSpacing="0" width="90%" border="1" align="center">
<tr>
<td>
<h2 class="docSidebarTitle">EXPLANATION</h2>
<span style="FONT-WEIGHT: bold">
<ol class="docList" type="1">
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The double quotes must be matched after the string
<span class="docEmphasis">"Hello.</span></span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">When a newline is entered, the secondary prompt
appears. Until the closing double quotes are entered, the secondary prompt
will be displayed.</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The output of the <span class="docEmphasis">print</span>
command is displayed.</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The primary prompt is displayed.</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The secondary prompt is reset.</span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">The double quotes must be matched after the string
<span class="docEmphasis">"Hi.</span></span></li>
<li><span style="FONT-WEIGHT: normal">
<p class="docList">When a newline is entered, the new secondary prompt
appears. Until the closing double quotes are entered, the secondary prompt
will be displayed.</span></li>
</ol>
</span></td>
</tr>
</table>
<h4 class="docSection2Title" id="ch10lev2sec4">10.1.4 The Search Path</h4>
<p class="docText">To execute a command typed at the command line or within a
shell script, the Korn shell searches the directories listed in the
<span class="docEmphasis">PATH</span> variable. The <span class="docEmphasis">
PATH</span> is a colon-separated list of directories, searched by the shell from
left to right. The dot in the <span class="docEmphasis">PATH</span> represents
the current working directory. If the command is not found in any of the
directories listed in the path, the shell sends the message
<span class="docEmphasis">ksh: filename: not found</span> to standard error. It
is recommended that the path be set in the <span class="docEmphasis">.profile</span>
file. To speed up the searching process, the Korn shell has implemented tracked
aliases. See "Tracked Aliases" on page 455.</p>
<h5 id="ch10list06" class="docExampleTitle">Example 10.6 </h5>
<pre>$ <span class="docEmphStrong">echo $PATH</span>
<span class="docEmphasis">/home/gsa12/bin:/usr/ucb:/usr/bin:/usr/local/bin:.</span>
</pre>
<table cellSpacing="0" width="90%" border="1" align="center">
<tr>
<td>
<h2 class="docSidebarTitle">EXPLANATION</h2>
<p class="docText">The Korn shell will search for commands starting in
<span class="docEmphasis">/home/gsa12/bin.</span> If the command is not
found there, <span class="docEmphasis">/usr/ucb</span> is searched, then
<span class="docEmphasis">/usr/bin, /usr/local/bin,</span> and finally the
user's home directory represented by the period.</td>
</tr>
</table>
<p class="docText"><b>The Dot Command.</b> The dot command (.) is a built-in
Korn shell command. It takes a scriptname as an argument. The script will be
executed in the environment of the current shell. A child process will not be
started. The dot command is normally used to reexecute the
<span class="docEmphasis">.profile</span> file or the <span class="docEmphasis">
ENV</span> file, if either of those files has been modified. For example, if one
of the settings in either file has been changed after you have logged on, you
can use the dot command to reexecute the initialization files without logging
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -