📄 sh5.1
字号:
Internal field separators,normally.BR space ,.BR tab ,and.BR new-line ..TP.B.SM SHELLWhen the shell is invoked, it scans the environment for this name. For further information, see.B Environmentbelow.If it is found and there is an 'r'in the file name part of its value, theshell becomes a restricted shell..PD.RE.PPThe shell gives default values to\fB\s-1PATH\s+1\fP, \fB\s-1PS1\s+1\fP, \fB\s-1PS2\s+1\fP, \fB\s-1MAILCHECK\s+1\fP and \fB\s-1IFS\s+1\fP..SM.B LOGNAME,.SM.B HOME,and.SM.B MAILare set by.MS login 1 ..SS Blank InterpretationAfter parameter and command substitution,the results of substitution are scanned for internal field separatorcharacters (those found in.BR \s-1IFS\s+1 )and split into distinct arguments where such characters are found.Explicit null arguments (\^\fB"\^"\fP or \fB'\^'\fP\^) are retained.Implicit null arguments,those resulting from parametersthat have no values are removed..SS File Name Generation.NXR "pattern" "matching"Following substitution, each commandword is scanned for the characters.BR \(** ,.BR ? ,and.BR [ .If one of these characters appearsthe word is regarded as apattern.The word is replaced with alphabetically sorted filenames that match the pattern.If no file name is found that matches the pattern,the word is left unchanged.The character.B .at the start of a file nameor immediately following a.BR / ,as well as the character.B /itself,must be matched explicitly..PP.PD 0.RS.TP.B \(**Matches any string, including the null string..TP.B ?Matches any single character..TP.BR [...]Matches any one of the enclosed characters.A pair of characters separated by.B \-matches anycharacter lexically between the pair, inclusive.If the first character following the opening ``[''is a.B "``!''"any character not enclosed is matched..PD.RE.SS Quoting.NXR "sh5 command interpreter" "special characters and"The following characters have a special meaning to the shelland cause termination of a word unless quoted:.RS.PP\fB; & ( ) | ^ < > new-line space tab\fP.RE.PPA character may be quoted(that is, made to stand for itself)by precedingit with a.BR \e .The pair.B \enew-lineis ignored.All characters enclosed between a pair of single quote marks (' '),except a single quote,are quoted.Inside double quote marks(\fB"\^"\fP),parameter and command substitution occurs and.B \equotes the characters.BR \e ,.BR ` ,\fB"\fP,and.BR $ ..B"$\(**"is equivalent to\fB"$1 \|$2\fP \|.\|.\|.\fB"\fP,whereas.B"$@"is equivalent to.B"$1"\|.B"$2"\|\&.\|.\|.\|..SS Prompting.NXR "sh5 command interpreter" "prompts"When used interactively,the shell prompts with the value of.SM.B PS1before reading a command.If at any time a new-line is typed and further input is neededto complete a command, the secondary prompt(that is, the value of.BR \s-1PS2\s+1 )is issued..SS Input/output.NXR "sh5 command interpreter" "directing input".NXR "sh5 command interpreter" "directing output"Before a command is executed, its input and outputmay be redirected using a special notation interpreted by the shell.The following may appear anywhere in a simple commandor may precede or follow acommand and are not passed on to the invoked command.Substitution occurs beforeword or digit is used:.PP.PD 0.TP 14\fB<\fIword\fPUse file.I word\^as standard input (file descriptor 0)..TP\fB>\fIword\fPUse file.I word\^as standard output (file descriptor 1).If the file does not exist it is created.Otherwise, it is truncated to zero length..TP\fB>\&>\&\fIword\fPUse file.I word\^as standard output.If the file exists output is appended to it,by first seeking to the end-of-file.Otherwise, the file is created..TP\fB<<[ \- ]\fIword\fPThe shell input is read up to a line that is the same as.IR word ,or to an end-of-file.The resulting document becomesthe standard input.If any character of.I word\^is quoted, no interpretationis placed upon the characters of the document.Otherwise, parameter and command substitution occurs,(unescaped).B \enew-lineis ignored,and.B \emust be used to quote the characters.BR \e ,.BR $ ,.BR ` ,and the first character of.IR word .If.B \-is appended to.BR <\h@-.3m@< ,all leading tabs are stripped from.I word\^and from the document..TP\fB<\h@-.1m@&\fIdigit\fPUse the file associated with file descriptor.I digit\^as standard input.Similarly for the standard output using .B >\h@-.1m@&\fIdigit\fP..TP.B <\h@-.1m@&\h@-.1m@\-The standard input is closed.Similarly for the standard output using.BR >\h@-.1m@&\h@-.1m@\- ..PD.PPIf any of the above is preceded by a digit,the file descriptor which will be associated with the file is that specified by the digit,instead of the default 0 or 1.For example:.EX ... 2>&1.EE.PPThis associates file descriptor 2with the file currently associated with file descriptor 1..PPThe order in which redirections are specified is significant.The shell evaluates redirections left-to-right.For example:.EX ... 1>xxx 2>&1.EE.PPThe first associates file descriptor 1 with file .IR xxx\^ .It associates file descriptor 2 with the file associated with filedescriptor 1 (that is,.IR xxx\^ ).If the order of redirections were reversed,file descriptor 2 would be associated with the terminal (assuming file descriptor 1 had been)and file descriptor 1 would be associated with file .IR xxx\^ ..PPIf a command is followed by.B &the default standard inputfor the commandis the empty file/dev/null.Otherwise, the environment for the execution of a command contains thefile descriptors of the invoking shell as modified byinput/output specifications..PPRedirection of output is not allowed in the restricted shell..SS Environment.NXR "sh5 command interpreter" "environment"The environmentis a list of name-value pairs that is passed toan executed program in the same way as a normal argument list.For further information, see .MS environ 7 .The shell interacts with the environment in several ways.On invocation, the shell scans the environmentand creates aparameterfor each name found,giving it the corresponding value.If the user modifies the value of any of theseparametersor creates new parameters,none of these affects the environmentunless the.B exportcommand is used to bind the shell'sparameterto the environment (see also .BR "set \-a" ).A parameter may be removed from the environmentwith the .BR unsetcommand.The environment seen by any executed command is thus composedof any unmodified name-value pairs originally inherited by the shell,minus any pairs removed by.BR unset ,plus any modifications or additions,all of which must be noted in.B exportcommands..PPThe environment for any simple commandmay be augmented by prefixing it with one or more assignments toparameters.Thus:.EXTERM=450 cmd (export TERM; TERM=450; cmd).EE.PPThese are equivalent (as far as the execution of.I cmd\^is concerned)..PPIf the.B \-kflag is set,.I all\^keyword arguments are placed in the environment,even if they occur after the command name.The followingfirst prints.B "a=b c"and.BR c :.EXecho a=b cset \-kecho a=b c.EE.SS Signals.NXR "sh5 command interpreter" "signals"The \s-1INTERRUPT\s+1 and \s-1QUIT\s+1 signals for an invokedcommand are ignored if the command is followed by.BR & .Otherwise signals have the valuesinherited by the shell from its parent,with the exception of signal 11.For further information, see alsothe.B trapcommand below..SS Execution.NXR "sh5 command interpreter" "executing commands"Each time a command is executed, the above substitutions arecarried out.If the command name matches one of the .B Special Commandslisted below, it is executed in the shell process.If the command name does not match a.B Special Command,but matches the name of a defined function, the function is executed in the shell process(note how this differs from the execution of shell procedures).The positional parameters.BR $1 ,.BR $2 ,\&.\|.\|.\|.are set to the arguments of the function.If the command name matches neither a.B Special Commandnor the name of a defined function,a new process is created and an attempt is made toexecute the command via.MS execve 2 ..PPThe shell parameter.B.SM PATHdefines the search path forthe directory containing the command.Alternative directory names are separated bya colon.RB ( : ).The default path is.B :/bin:/usr/bin(specifying the current directory,.BR /bin ,and.BR /usr/bin ,in that order).Note that the current directory is specified by a null path name,which can appear immediately after the equal signor between the colon delimiters anywhere else in the path list.If the command name contains a \fB/\fP the search pathis not used.Such commands will not be executed by the restricted shell.Otherwise, each directory in the path issearched for an executable file.If the file has execute permission but is not an.B a.outfile,it is assumed to be a file containing shell commands.A sub-shell is spawned to read it.A parenthesized command is also executed ina sub-shell..PPThe location in the search path where a command was found is remembered by theshell(to help avoid unnecessary.B execlater).If the command was found in a relative directory, its location must be re-determined whenever the current directory changes.The shell forgets all remembered locations whenever the.B .SM PATHvariable is changed or the.B hash \-rcommand is executed (see below)..SS Special CommandsInput/output redirection is now permitted for these commands.File descriptor 1 is the default output location..PP.PD 0.TP.B :No effect; the command does nothing.A zero exit code is returned..br.TP.BI ".\| " file\^Read and execute commands from.I file\^and return.The search pathspecified by.B.SM PATHis used to find the directory containing.IR file ..TP\fBbreak\fP [ \fIn\fP ].NXR "break command (System V)"Exit from the enclosing \fBfor\fP or.B whileloop, if any.If.I n\^is specified break.I n\^levels..TP\fBcontinue\fP [ \fIn\fP ].NXR "continue command (System V)"Resume the next iteration of the enclosing\fBfor\fP or.B whileloop.If.I n\^is specified resume at the.IR n \-thenclosing loop..TP\fBcd\fP [ \fIarg\fP ].NXR "cd command (System V)"Change the current directory to.IR arg .The shellparameter.B.SM HOMEis the default.IR arg .The shell parameter.B.SM CDPATHdefines the search path forthe directory containing .IR arg .Alternative directory names are separated bya colon.RB ( : ).The default path is.B <null>(specifying the current directory).Note that the current directory is specified by a null path name,which can appear immediately after the equal signor between the colon delimiters anywhere else in the path list.If .I argbegins with a \fB/\fP the search pathis not used.Otherwise, each directory in the path is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -