bash.1

来自「android-w.song.android.widget」· 1 代码 · 共 2,303 行 · 第 1/5 页

1
2,303
字号
is connected via a pipe to a file descriptor in the executing shell,and that file descriptor is assigned to \fINAME\fP[0].The standard input of.I commandis connected via a pipe to a file descriptor in the executing shell,and that file descriptor is assigned to \fINAME\fP[1].This pipe is established before any redirections specified by thecommand (see.SM.B REDIRECTIONbelow).The file descriptors can be utilized as arguments to shell commandsand redirections using standard word expansions.The process ID of the shell spawned to execute the coprocess isavailable as the value of the variable \fINAME\fP_PID.The \fBwait\fPbuiltin command may be used to wait for the coprocess to terminate..PPThe return status of a coprocess is the exit status of \fIcommand\fP..SS Shell Function Definitions.PPA shell function is an object that is called like a simple command andexecutes a compound command with a new set of positional parameters.Shell functions are declared as follows:.TP\fIname\fP () \fIcompound\-command\fP [\fIredirection\fP].PD 0.TP\fBfunction\fP \fIname\fP [()] \fIcompound\-command\fP [\fIredirection\fP].PDThis defines a function named \fIname\fP.The reserved word \fBfunction\fP is optional.If the \fBfunction\fP reserved word is supplied, the parentheses are optional.The \fIbody\fP of the function is the compound command.I compound\-command (see \fBCompound Commands\fP above).That command is usually a \fIlist\fP of commands between { and }, butmay be any command listed under \fBCompound Commands\fP above.\fIcompound\-command\fP is executed whenever \fIname\fP is specified as thename of a simple command.Any redirections (see.SM.B REDIRECTIONbelow) specified when a function is defined are performedwhen the function is executed.The exit status of a function definition is zero unless a syntax erroroccurs or a readonly function with the same name already exists.When executed, the exit status of a function is the exit status of thelast command executed in the body.  (See.SM.B FUNCTIONSbelow.).SH COMMENTSIn a non-interactive shell, or an interactive shell in which the.B interactive_commentsoption to the.B shoptbuiltin is enabled (see.SM.B "SHELL BUILTIN COMMANDS"below), a word beginning with.B #causes that word and all remaining characters on that line tobe ignored.  An interactive shell without the.B interactive_commentsoption enabled does not allow comments.  The.B interactive_commentsoption is on by default in interactive shells..SH QUOTING\fIQuoting\fP is used to remove the special meaning of certaincharacters or words to the shell.  Quoting can be used to disable special treatment for special characters, to preventreserved words from being recognized as such, and to preventparameter expansion..PPEach of the \fImetacharacters\fP listed above under.SM.B DEFINITIONShas special meaning to the shell and must be quoted if it is torepresent itself..PPWhen the command history expansion facilities are being used(see.SM.B HISTORY EXPANSIONbelow), the\fIhistory expansion\fP character, usually \fB!\fP, must be quotedto prevent history expansion..PPThere are three quoting mechanisms: the.IR "escape character" ,single quotes, and double quotes..PPA non-quoted backslash (\fB\e\fP) is the.IR "escape character" .It preserves the literal value of the next character that follows,with the exception of <newline>.  If a \fB\e\fP<newline> pairappears, and the backslash is not itself quoted, the \fB\e\fP<newline>is treated as a line continuation (that is, it is removed from theinput stream and effectively ignored)..PPEnclosing characters in single quotes preserves the literal valueof each character within the quotes.  A single quote may not occurbetween single quotes, even when preceded by a backslash..PPEnclosing characters in double quotes preserves the literal valueof all characters within the quotes, with the exception of.BR $ ,.BR \` ,.BR \e ,and, when history expansion is enabled,.BR ! .The characters.B $and.B \`retain their special meaning within double quotes.  The backslashretains its special meaning only when followed by one of the followingcharacters:.BR $ ,.BR \` ,\^\fB"\fP\^,.BR \e ,or.BR <newline> .A double quote may be quoted within double quotes by preceding it witha backslash.If enabled, history expansion will be performed unless an.B !appearing in double quotes is escaped using a backslash.The backslash preceding the.B !is not removed..PPThe special parameters.B *and.B @have special meaning when in doublequotes (see.SM.B PARAMETERSbelow)..PPWords of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially.  Theword expands to \fIstring\fP, with backslash-escaped characters replacedas specified by the ANSI C standard.  Backslash escape sequences, ifpresent, are decoded as follows:.RS.PD 0.TP.B \eaalert (bell).TP.B \ebbackspace.TP.B \ee.TP.B \eEan escape character.TP   .B \efform feed.TP  .B \ennew line.TP     .B \ercarriage return.TP.B \ethorizontal tab.TP   .B \evvertical tab.TP.B \e\ebackslash.TP.B \e\(aqsingle quote.TP.B \e\(dqdouble quote.TP   .B \e\fInnn\fPthe eight-bit character whose value is the octal value \fInnn\fP(one to three digits).TP.B \ex\fIHH\fPthe eight-bit character whose value is the hexadecimal value \fIHH\fP(one or two hex digits).TP.B \eu\fIHHHH\fPthe Unicode (ISO/IEC 10646) character whose value is the hexadecimal value\fIHHHH\fP (one to four hex digits).TP.B \eU\fIHHHHHHHH\fPthe Unicode (ISO/IEC 10646) character whose value is the hexadecimal value\fIHHHHHHHH\fP (one to eight hex digits).TP.B \ec\fIx\fPa control-\fIx\fP character.PD.RE.LPThe expanded result is single-quoted, as if the dollar sign hadnot been present..PPA double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq)will cause the string to be translated according to the current locale.If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar signis ignored.If the string is translated and replaced, the replacement isdouble-quoted..SH PARAMETERSA.I parameteris an entity that stores values.It can be a.IR name ,a number, or one of the special characters listed below under.BR "Special Parameters" .A.I variableis a parameter denoted by a.IR name .A variable has a \fIvalue\fP and zero or more \fIattributes\fP.Attributes are assigned using the.B declarebuiltin command (see.B declarebelow in.SM.BR "SHELL BUILTIN COMMANDS" )..PPA parameter is set if it has been assigned a value.  The null string isa valid value.  Once a variable is set, it may be unset only by usingthe.B unsetbuiltin command (see.SM.B SHELL BUILTIN COMMANDSbelow)..PPA.I variablemay be assigned to by a statement of the form.RS.PP\fIname\fP=[\fIvalue\fP].RE.PPIf.I valueis not given, the variable is assigned the null string.  All.I valuesundergo tilde expansion, parameter and variable expansion,command substitution, arithmetic expansion, and quoteremoval (see.SM.B EXPANSIONbelow).  If the variable has its.B integerattribute set, then.I valueis evaluated as an arithmetic expression even if the $((...)) expansion isnot used (see.B "Arithmetic Expansion"below).Word splitting is not performed, with the exceptionof \fB"$@"\fP as explained below under.BR "Special Parameters" .Pathname expansion is not performed.Assignment statements may also appear as arguments to the.BR alias ,.BR declare ,.BR typeset ,.BR export ,.BR readonly ,and.B localbuiltin commands..PPIn the context where an assignment statement is assigning a valueto a shell variable or array index, the += operator can be used toappend to or add to the variable's previous value.When += is applied to a variable for which the \fIinteger\fP attribute has beenset, \fIvalue\fP is evaluated as an arithmetic expression and added to thevariable's current value, which is also evaluated.When += is applied to an array variable using compound assignment (see.B Arraysbelow), thevariable's value is not unset (as it is when using =), and new values areappended to the array beginning at one greater than the array's maximum index(for indexed arrays) or added as additional key\-value pairs in anassociative array.When applied to a string-valued variable, \fIvalue\fP is expanded andappended to the variable's value..SS Positional Parameters.PPA.I positional parameteris a parameter denoted by one or moredigits, other than the single digit 0.  Positional parameters areassigned from the shell's arguments when it is invoked,and may be reassigned using the.B setbuiltin command.  Positional parameters may not be assigned towith assignment statements.  The positional parameters aretemporarily replaced when a shell function is executed (see.SM.B FUNCTIONSbelow)..PPWhen a positional parameter consisting of more than a singledigit is expanded, it must be enclosed in braces (see.SM.B EXPANSIONbelow)..SS Special Parameters.PPThe shell treats several parameters specially.  These parameters mayonly be referenced; assignment to them is not allowed..PD 0.TP.B *Expands to the positional parameters, starting from one.  When theexpansion occurs within double quotes, it expands to a single wordwith the value of each parameter separated by the first characterof the .SM.B IFSspecial variable.  That is, "\fB$*\fP" is equivalentto "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where.I cis the first character of the value of the.SM.B IFSvariable.  If.SM.B IFSis unset, the parameters are separated by spaces.If.SM.B IFSis null, the parameters are joined without intervening separators..TP.B @Expands to the positional parameters, starting from one.  When theexpansion occurs within double quotes, each parameter expands to aseparate word.  That is, "\fB$@\fP" is equivalent to"\fB$1\fP" "\fB$2\fP" ...If the double-quoted expansion occurs within a word, the expansion ofthe first parameter is joined with the beginning part of the originalword, and the expansion of the last parameter is joined with the lastpart of the original word.When there are no positional parameters, "\fB$@\fP" and .B $@expand to nothing (i.e., they are removed)..TP.B #Expands to the number of positional parameters in decimal..TP.B ?Expands to the exit status of the most recently executed foregroundpipeline..TP.B \-Expands to the current option flags as specified upon invocation, by the.B setbuiltin command, or those set by the shell itself(such as the.B \-ioption)..TP.B $Expands to the process ID of the shell.  In a () subshell, itexpands to the process ID of the current shell, not thesubshell..TP.B !Expands to the process ID of the most recently executed background(asynchronous) command..TP.B 0Expands to the name of the shell or shell script.  This is set atshell initialization.  If.B bashis invoked with a file of commands,.B $0is set to the name of that file.  If.B bashis started with the.B \-coption, then.B $0is set to the first argument after the string to beexecuted, if one is present.  Otherwise, it is setto the file name used to invoke.BR bash ,as given by argument zero..TP.B _At shell startup, set to the absolute pathname used to invoke theshell or shell script being executed as passed in the environmentor argument list.Subsequently, expands to the last argument to the previous command,after expansion.Also set to the full pathname used to invoke each command executedand placed in the environment exported to that command.When checking mail, this parameter holds the name of the mail filecurrently being checked..PD.SS Shell Variables.PPThe following variables are set by the shell:.PP.PD 0.TP.B BASHExpands to the full file name used to invoke this instance of.BR bash ..TP.B BASHOPTSA colon-separated list of enabled shell options.  Each word inthe list is a valid argument for the.B \-soption to the.B shoptbuiltin command (see.SM.B "SHELL BUILTIN COMMANDS"below).  The options appearing in.SM.B BASHOPTSare those reported as.I onby \fBshopt\fP.If this variable is in the environment when.B bashstarts up, each shell option in the list will be enabled beforereading any startup files.This variable is read-only..TP.B BASHPIDExpands to the process ID of the current \fBbash\fP process.This differs from \fB$$\fP under certain circumstances, such as subshellsthat do not require \fBbash\fP to be re-initialized..TP.B BASH_ALIASESAn associative array variable whose members correspond to the internallist of aliases as maintained by the \fBalias\fP builtin.Elements added to this array appear in the alias list; unsetting arrayelements cause aliases to be removed from the alias list..TP.B BASH_ARGCAn array variable whose values are the number of parameters in eachframe of the current \fBbash\fP execution call stack.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?