📄 sh.html
字号:
Tilde Expansion</a></xref>.<dt><i>IFS</i><dd><i>Input field separators :</i>a string treated as a list of charactersthat is used for field splitting and tosplit lines into words with the<i><a href="read.html">read</a></i>command.See<xref href=fldspl><a href="chap2.html#tag_001_006_005">Field Splitting</a></xref>.If<i>IFS</i>is not set, the shell behaves as if the value of<i>IFS</i>were thespace,tabandnewlinecharacters.Implementations may ignore the value of<i>IFS</i>in the environment at the time<i>sh</i>is invoked, treating<i>IFS</i>as if it were not set.<dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the behaviour of rangeexpressions, equivalence classes and multi-character collating elementswithin pattern matching.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text dataas characters (for example, single-versus multi-byte characters in arguments and input files),which characters are defined asletters (character class<b>alpha</b>),and the behaviour of character classes within pattern matching.<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>MAIL</i><dd>Determine a pathname of the user's mailbox filefor purposes of incoming mail notification.If this variable is set,the shell will inform the user if the file namedby the variable is created or if its modification time has changed.Informing the user is accomplished by writing a stringof unspecified formatto standard error prior to the writing ofthe next primary prompt stringafter the completion of an interval defined by the<i>MAILCHECK</i>variable.The user will be informed only if<i>MAIL</i>is set and<i>MAILPATH</i>is not set.<dt><i>MAILCHECK</i><dd>Establish a decimal integervalue that specifies how often (in seconds) the shellwill check for the arrival of mail in the files specified by the<i>MAILPATH</i>or<i>MAIL</i>variables.The default value is 600 seconds.If set to zero, the shell will check before issuing each primary prompt.<dt><i>MAILPATH</i><dd>Provide a list of pathnamesand optional messages separated by colons.If this variable is set, the shell will informthe user if any of the files named by the variable are created orif any of their modification times change.(See the preceding entry for<i>MAIL</i>for descriptions of mail arrival and user informing.)Each pathname can be followed by"%"and a string that will besubjected to parameter expansion andwritten to standard error when themodification time changes.If a"%"character in the pathname is preceded by a backslash,it will be treated as a literal"%"in the pathname.The default message is unspecified.The<i>MAILPATH</i>environment variable takes precedence over the<i>MAIL</i>variable.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i><dt><i>PATH</i><dd>Establish a string formatted as described inthe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> ,used to effect command interpretation.See<xref href=cmdsea><a href="chap2.html#tag_001_009_001_001">Command Search and Execution</a></xref>.</dl></blockquote><h4><a name = "tag_001_014_2000"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_2001"> </a>STDOUT</h4><blockquote>See the STDERR section.<br></blockquote><h4><a name = "tag_001_014_2002"> </a>STDERR</h4><blockquote>Except as otherwise stated (by the descriptions of anyinvoked utilities or in interactive mode),standard error isused only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_2003"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_2004"> </a>EXTENDED DESCRIPTION</h4><blockquote>See<xref href=shell><a href="chap2.html#tag_001">Shell Command Language</a></xref>.The following additional capabilities are supported.<h5><a name = "tag_001_014_2004_001"> </a>Command History List</h5><xref type="5" name="shcmdhist"></xref>When the<i>sh</i>utility is being used interactively,it maintains a list of commands previously enteredfrom the terminalin the file named by the<i>HISTFILE</i>environment variable.The type, size and internal format of this file are unspecified.Multiple<i>sh</i>processes can share access to the file for a user,if file access permissions allow this;see the description of the<i>HISTFILE</i>environment variable.<h5><a name = "tag_001_014_2004_002"> </a>Command Line Editing</h5>When<i>sh</i>is being used interactively from a terminal, the currentcommand and the command history (see<i><a href="fc.html">fc</a></i>)can be edited using<i>vi-mode</i>command line editing.This mode uses commands, described below,similar to a subset of those described in the<i><a href="vi.html">vi</a></i>utility.Implementations may offer other command line editing modescorresponding to other editing utilities.<p>The command<i>set</i><b>-o</b><b>v</b>enables vi-mode editing and places<i>sh</i>into<i><a href="vi.html">vi</a></i>insert mode (see<xref href=shvicle><a href="#tag_001_014_2004_003">Command Line Editing (vi-mode)</a></xref>).This command also disables any otherediting mode that the implementation may provide.The command<i>set</i><b>+o</b><b>v</b>disables vi-mode editing.<p>Certain block-mode terminals may be unable to support shell commandline editing.If a terminal is unable to provide either edit mode,it need not be possible to<i>set</i><b>-o</b><b>v</b>when using the shell on this terminal.<p>In the following sections, the characterserase,interrupt,killandend-of-fileare those set by the<i><a href="stty.html">stty</a></i>utility.<h5><a name = "tag_001_014_2004_003"> </a>Command Line Editing (vi-mode)</h5><xref type="5" name="shvicle"></xref>With vi-mode enabled,<i>sh</i>can be switched between insert mode and command mode.<p>When in insert mode, an entered characterwill be inserted into the command line,except as noted in<xref href=shvieim><a href="#tag_001_014_2004_004">vi Line Editing Insert Mode</a></xref>.Upon entering<i>sh</i>and after termination of the previous command,<i>sh</i>will be in insert mode.<p>Typing an escape character wll switch<i>sh</i>into command mode (see<xref href=shviecm><a href="#tag_001_014_2004_005">vi Line Editing Command Mode</a></xref>).In command mode, an entered character will either invoke a definedoperation, be used as part of a multi-character operationor be treated as an error.A character that is not recognised as part of an editingcommand will terminate any specific editing command andwill alert the terminal.Typing the<i>interrupt</i>character in command mode will cause<i>sh</i>to terminate command line editing on thecurrent command line, reissue theprompt on the next line of the terminaland reset the command history (see<i><a href="fc.html">fc</a></i>)so that the most recently executed commandis the previous command (that is, thecommand that was being edited when it wasinterrupted is not reentered into the history).<p>In the following sections, the phrase "move the cursor to thebeginning of the word" means "move the cursor to the firstcharacter of the current word" and the phrase "move the cursor to theend of the word" means "move the cursor to the lastcharacter of the current word".The phrase "beginning of the command line" indicatesthe point between the end of the prompt string issued by the shell(or the beginning of the terminal line, if there is no prompt string)and the first character of the command text.<h5><a name = "tag_001_014_2004_004"> </a>vi Line Editing Insert Mode</h5><xref type="5" name="shvieim"></xref>While in insert mode, any character typed will be inserted in thecurrent command line, unless it is from the following set.<dl compact><dt>newline<dd>Execute the current command line being edited.<dt><i>erase</i><dd>Delete the character previous to the current cursor positionand move the current cursor position back one character.In insert mode, characters will be erased from both the screen andthe buffer when backspacing.<dt><i>interrupt</i><dd>Terminate command line editing with the same effectsas described for interrupting command mode; see<xref href=shvicle><a href="#tag_001_014_2004_003">Command Line Editing (vi-mode)</a></xref>.<dt><i>kill</i><dd>Clear all the characters from the input line.<dt><control>-V<dd>Insert the next character input, even if the characteris otherwise a special insert mode character.<dt><control>-W<dd>Delete the characters from the one preceding the cursor tothe preceding word boundary.The word boundary in this caseis the closer to the cursor ofeither the beginning of the line or a character that isin neither the<b>blank</b>nor<b>punct</b>character classification of the current locale.<dt><b>\</b><dd>On some systems, when a backslash is followed by an<i>erase</i>or<i>kill</i>character, that character will be inserted into the input line.This is not actually a feature of<i>sh</i>command line editing insert mode, but one ofterminal line drivers when the<i><a href="stty.html">stty</a></i><b>iexten</b>flag is set.Otherwise, the backslash itself will be inserted into the input line.<dt><i>end-of-file</i><dd>Interpreted as the end of input in<i>sh</i>.This interpretation will occur only at the beginning of an input line.If end-of-file is entered other than at the beginning of the line,the results are unspecified.<dt><ESC><dd>Place<i>sh</i>into command mode.</dl><h5><a name = "tag_001_014_2004_005"> </a>vi Line Editing Command Mode</h5><xref type="5" name="shviecm"></xref>In command mode for the command line editing feature, decimaldigits not beginning with 0 that precede a command letter will be remembered.Some commands use these decimal digits as a count numberthat affects the operation.<p>The term<i>motion command</i>represents one of the commands:<pre><code><space> 0 b F l W ^ $ ; E f T w | , B e h t</code></pre><p>Any command that modifies the current line will cause a copy of thecurrent line to be made at the end of thecommand history, the currentline will become that copy,and the edit will be performed on that copy.<p>Any command that is preceded by<i>count</i>will take a count (the numericvalue of any preceding decimal digits).Unless otherwise noted, thiscount will cause the specified operation to repeat by the number oftimes specified by the count.Also unless otherwise noted, a<i>count</i>that is out of range is considered an error condition andwill alert the terminal,but neither the cursor position,nor the command line, will change.<p>The terms<i>word</i>and<i>bigword</i>are used as defined in the<i><a href="vi.html">vi</a></i>description.The term<i>save buffer</i>corresponds to the term<i>unnamed buffer</i>in<i><a href="vi.html">vi</a></i>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -