📄 _chapter 13.htm
字号:
2 setenv PATH "${PATH}:/usr/X11R6/bin"
else
3 setenv PATH "/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
endif
4 if ($?prompt) then
5 [ "$SHELL" = /bin/tcsh ]
6 if ($status == 0) then
7 set prompt='[%n@%m %c]$ '
8 else
9 set prompt=\['id -nu'@'hostname -s'\]\$\
10 endif
endif
11 limit coredumpsize 1000000
12 [ 'id -gn' = 'id -un' -a 'id -u' -gt 14 ]
13 if $status then
14 umask 022
else
15 umask 002
endif
16 setenv HOSTNAME '/bin/hostname'
17 set history=1000
18 test -d /etc/profile.d
19 if ($status == 0) then
20 set nonomatch
21 foreach i ( /etc/profile.d/*.csh )
22 test -f $i
if ($status == 0) then
23 source $i
endif
end
24 unset nonomatch
endif</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"><span class="docEmphasis">$?PATH</span> is a test to
see if the <span class="docEmphasis">PATH</span> variable has been set; it
returns <span class="docEmphasis">1</span> if true.</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the <span class="docEmphasis">PATH</span> variable
has been set, <span class="docEmphasis">/usr/X11R6/bin</span> is appended
to it. This is a directory that contains the <span class="docEmphasis">X</span>
windows files.</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the <span class="docEmphasis">PATH</span> variable
has not been previously set, this line sets it to
<span class="docEmphasis">/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin</span></span></li>
<li><span style="font-weight: normal">
<p class="docList">This line checks to see if the prompt has been set.</span></li>
<li><span style="font-weight: normal">
<p class="docList">When you place the expression in square brackets, the
expression will be tested and if the result of the expression is true, a
zero exit status is returned; otherwise a nonzero exit status is returned.
If the value of the <span class="docEmphasis">SHELL</span> environment
variable is <span class="docEmphasis">/bin/tcsh,</span> the exit status
will be <span class="docEmphasis">0.</span></span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">status</span> variable
contains the exit status of the last command executed, which in this
example, is the previous test on line 5.</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the status from the last command was zero, the
prompt for the <span class="docEmphasis">/bin/tcsh</span> is set. The
prompt will be set to the user's name followed by an @ symbol, the
hostname, and the current working directory (all enclosed in
<span class="docEmphasis">[ ]</span> ), followed by a dollar sign; e.g.,
<span class="docEmphasis">[ ellie@homebound ~ ]$</span></span></li>
<li><span style="font-weight: normal">
<p class="docList">If the status was nonzero, the
<span class="docEmphasis">else</span> branches program control to line 9.</span></li>
<li><span style="font-weight: normal">
<p class="docList">This line sets the prompt for the standard
<span class="docEmphasis">csh</span> program. It will print the user's
name (<span class="docEmphasis">id -un</span>), an
<span class="docEmphasis">@</span> symbol, and the short name for his host
machine, i.e., the hostname cut at the first dot, and a
<span class="docEmphasis">$.</span></span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">endif</span> terminates
the inner <span class="docEmphasis">if</span> block.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The size of core files (usually created when a program
crashes for some illegal system operation) is limited to 1,000,000 bytes.
Core files are created if you abort a running program with Control-\.</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the group ID number and the user ID number are the
same, and the user ID number is greater than 14, then the next line will
be executed; otherwise, the line under the <span class="docEmphasis">else</span>
will be executed. Typically, user IDs below 14 are for special users, such
as <span class="docEmphasis">root, daemon, adm,</span>
<span class="docEmphasis">lp,</span> etc. (See <span class="docEmphasis">
/etc/passwd.</span> The user ID is in field number 3.)</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the test in the previous line returned a nonzero
exit status, line 14 is executed, else line 15 is executed.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">umask</span> command sets
the file creation mask; i.e., the initial permissions for files and
directories when created. Directories will get <span class="docEmphasis">
755</span> (<span class="docEmphasis">rwxr-xr-x</span>) and files will get
<span class="docEmphasis">644</span> (<span class="docEmphasis">rw-r--r--</span>)
when they are created.</span></li>
<li><span style="font-weight: normal">
<p class="docList"><span class="docEmphasis">Umask</span> is set so that
when a directory is created, its permissions will be
<span class="docEmphasis">775</span> (<span class="docEmphasis">rwxrwxr-x</span>)
and files will get <span class="docEmphasis">664</span> (<span class="docEmphasis">rw-rw-r--</span>).
</span></li>
<li><span style="font-weight: normal">
<p class="docList">The environment variable <span class="docEmphasis">
HOSTNAME</span> is assigned the output of the <span class="docEmphasis">
/bin/hostname</span> command.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">history</span> variable
is set to <span class="docEmphasis">1000.</span> When commands are typed
at the command line, they are saved in a history list. When you set the
history variable to <span class="docEmphasis">1000,</span> no more than
1,000 commands will be displayed when the <span class="docEmphasis">
history</span> command is typed.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">test</span> command
returns zero exit status if the <span class="docEmphasis">/etc/profile.d</span>
directory exists, and nonzero if it doesn't.</span></li>
<li><span style="font-weight: normal">
<p class="docList">If the status is <span class="docEmphasis">0,</span>
the directory exists, and the program branches to line 20.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">nonomatch</span> variable
is set to prevent the shell from sending an error message if any of its
special metacharacters (<span class="docEmphasis">*,</span>
<span class="docEmphasis">?,</span> <span class="docEmphasis">[]</span>)
cannot be matched.</span></li>
<li><span style="font-weight: normal">
<p class="docList">The <span class="docEmphasis">foreach</span> loop
assigns each file with a <span class="docEmphasis">.csh</span> extension (<span class="docEmphasis">*.csh</span>)
in the <span class="docEmphasis">/etc/profile.d</span> directory to the
variable <span class="docEmphasis">i,</span> in turn, looping until each
file has been tested (lines 22
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -