📄 ksh.man
字号:
the shell to recognize a parameter assignment.The fourth way of setting a parameter is with the \fBexport\fP, \fBreadonly\fPand \fBtypeset\fP commands; see their descriptions in the Command Executionsection.Fifth, \fBfor\fP and \fBselect\fP loops set parameters as well asthe \fBgetopts\fP, \fBread\fP and \fBset \-A\fP commands.Lastly, parameters can be assigned values using assignment operatorsinside arithmetic expressions (see Arithmetic Expressions below) orusing the \fB${\fP\fIname\fP\fB=\fP\fIvalue\fP\fB}\fP formof parameter substitution (see below)..\"}}}.PP.\"{{{ environmentParameters with the export attribute (set using the \fBexport\fP or\fBtypeset \-x\fP commands, or by parameter assignments followed by simplecommands) are put in the environment (see \fIenviron\fP(5)) of commandsrun by the shell as \fIname\fP\fB=\fP\fIvalue\fP pairs.The order in which parameters appear in the environment of a commandis unspecified.When the shell starts up, it extracts parameters and their values from itsenvironment and automatically sets the export attribute for those parameters..\"}}}.\"{{{ ${name[:][-+=?]word}.PPModifiers can be applied to the \fB${\fP\fIname\fP\fB}\fP form of parametersubstitution:.IP \fB${\fP\fIname\fP\fB:-\fP\fIword\fP\fB}\fPif \fIname\fP is set and not null, it is substituted, otherwise \fIword\fP issubstituted..IP \fB${\fP\fIname\fP\fB:+\fP\fIword\fP\fB}\fPif \fIname\fP is set and not null, \fIword\fP is substituted, otherwise nothing is substituted..IP \fB${\fP\fIname\fP\fB:=\fP\fIword\fP\fB}\fPif \fIname\fP is set and not null, it is substituted, otherwise it isassigned \fIword\fP and the resulting value of \fIname\fP is substituted..IP \fB${\fP\fIname\fP\fB:?\fP\fIword\fP\fB}\fPif \fIname\fP is set and not null, it is substituted, otherwise \fIword\fPis printed on standard error (preceded by \fIname\fP:) and an error occurs(normally causing termination of a shell script, function or \&.-script).If word is omitted the string `parameter null or not set' is used instead..PPIn the above modifiers, the \fB:\fP can be omitted, in which case theconditions only depend on \fIname\fP being set (as opposed to set andnot null).If \fIword\fP is needed, parameter, command, arithmetic and tilde substitutionare performed on it; if \fIword\fP is not needed, it is not evaluated..\"}}}.PPThe following forms of parameter substitution can also be used:.\"{{{ ${#name}.IP \fB${#\fP\fIname\fP\fB}\fPThe number of positional parameters if \fIname\fP is \fB*\fP, \fB@\fP oris not specified,or the length of the string value of parameter \fIname\fP..\"}}}.\"{{{ ${#name[*]}, ${#name[@]}.IP "\fB${#\fP\fIname\fP\fB[*]}\fP, \fB${#\fP\fIname\fP\fB[@]}\fP"The number of elements in the array \fIname\fP..\"}}}.\"{{{ ${name#pattern}, ${name##pattern}.IP "\fB${\fP\fIname\fP\fB#\fP\fIpattern\fP\fB}\fP, \fB${\fP\fIname\fP\fB##\fP\fIpattern\fP\fB}\fP"If \fIpattern\fP matches the beginning of the value of parameter \fIname\fP,the matched text is deleted from the result of substitution. A single\fB#\fP results in the shortest match, two \fB#\fP's results in thelongest match..\"}}}.\"{{{ ${name%pattern}, ${name%%pattern}.IP "\fB${\fP\fIname\fP\fB%\fP\fIpattern\fP\fB}\fP, \fB${\fP\fIname\fP\fB%%\fP\fIpattern\fP\fB}\fP"Like \fB${\fP..\fB#\fP..\fB}\fP substitution, but it deletes from the end of thevalue..\"}}}.\"{{{ special shell parameters.PPThe following special parameters are implicitly set by the shell and cannot beset directly using assignments:.\"{{{ !.IP \fB!\fPProcess id of the last background process started. If no backgroundprocesses have been started, the parameter is not set..\"}}}.\"{{{ #.IP \fB#\fPThe number of positional parameters (\fIi.e.\fP, \fB$1\fP, \fB$2\fP,\fIetc.\fP)..\"}}}.\"{{{ $.IP \fB$\fPThe process ID of the shell, or the PID of the original shell ifit is a subshell..\"}}}.\"{{{ -.IP \fB\-\fPThe concatenation of the current single letter options(see \fBset\fP command below for list of options)..\"}}}.\"{{{ ?.IP \fB?\fPThe exit status of the last non-asynchronous command executed.If the last command was killed by a signal, \fB$?\fP is set to 128 plusthe signal number..\"}}}.\"{{{ 0.IP "\fB0\fP"The name the shell was invoked with (\fIi.e.\fP, \fBargv[0]\fP), or the\fBcommand-name\fP if it was invoked with the \fB\-c\fP option and the\fBcommand-name\fP was supplied, or the \fIfile\fP argument, if it wassupplied.If the \fBposix\fP option is not set, \fB$0\fP is the name of the currentfunction or script..\"}}}.\"{{{ 1-9.IP "\fB1\fP ... \fB9\fP"The first nine positional parameters that were supplied to the shell,function or \fB.\fP-script.Further positional parameters may be accessed using\fB${\fP\fInumber\fP\fB}\fP..\"}}}.\"{{{ *.IP \fB*\fPAll positional parameters (except parameter 0), \fIi.e.\fP, \fB$1 $2 $3\fP....If used outside of double quotes, parameters are separate words(which are subjected to word splitting); if used within double quotes,parameters are separated by the first character of the \fBIFS\fP parameter(or the empty string if \fBIFS\fP is null)..\"}}}.\"{{{ @.IP \fB@\fPSame as \fB$*\fP, unless it is used inside double quotes, in which casea separate word is generated for each positional parameter \- if thereare no positional parameters, no word is generated ("$@" can be usedto access arguments, verbatim, without loosing null arguments orsplitting arguments with spaces)..\"}}}.\"}}}.\"{{{ general shell parameters.PPThe following parameters are set and/or used by the shell:.\"{{{ _.ksh(.IP "\fB_\fP \fI(underscore)\fP"When an external command is executed by the shell, this parameter isset in the environment of the new process to the path of the executedcommand.In interactive use, this parameter is also set in the parent shell tothe last word of the previous command.When \fBMAILPATH\fP messages are evaluated, this parameter containsthe name of the file that changed (see \fBMAILPATH\fP parameter below)..ksh).\"}}}.\"{{{ CDPATH.IP \fBCDPATH\fPSearch path for the \fBcd\fP built-in command. Works the same way as\fBPATH\fP for those directories not beginning with \fB/\fP in \fBcd\fPcommands.Note that if CDPATH is set and does not contain \fB.\fP nor an empty path,the current directory is not searched..\"}}}.\"{{{ COLUMNS.IP \fBCOLUMNS\fPSet to the number of columns on the terminal or window.Currently set to the \fBcols\fP value as reported by \fIstty\fP(1) if thatvalue is non-zero.This parameter is used by the interactive line editing modes, and by\fBselect\fP, \fBset \-o\fP and \fBkill \-l\fP commandsto format information in columns..\"}}}.\"{{{ EDITOR.ksh(.IP \fBEDITOR\fPIf the \fBVISUAL\fP parameter is not set, this parameter controls thecommand line editing mode for interactive shells.See \fBVISUAL\fP parameter below for how this works..ksh).\"}}}.\"{{{ ENV.IP \fBENV\fPIf this parameter is found to be set after any profile files areexecuted, the expanded value is used as a shell start-up file. Ittypically contains function and alias definitions..\"}}}.\"{{{ ERRNO.IP \fBERRNO\fPInteger value of the shell's errno variable \(em indicates the reasonthe last system call failed..\" todo: ERRNO variable.spNot implemented yet..\"}}}.\"{{{ EXECSHELL.IP \fBEXECSHELL\fPIf set, this parameter is assumed to contain the shell that is to beused to execute commands that \fIexecve\fP(2) fails to execute andwhich do not start with a `\fB#!\fP \fIshell\fP' sequence..\"}}}.\"{{{ FCEDIT.IP \fBFCEDIT\fPThe editor used by the \fBfc\fP command (see below)..\"}}}.\"{{{ FPATH.IP \fBFPATH\fPLike \fBPATH\fP, but used when an undefined function is executed to locatethe file defining the function.It is also searched when a command can't be found using \fBPATH\fP.See Functions below for more information..\"}}}.\"{{{ HISTFILE.ksh(.IP \fBHISTFILE\fPThe name of the file used to store history.When assigned to, history is loaded from the specified file.Also, several invocations of theshell running on the same machine will share history if their\fBHISTFILE\fP parameters all point at the same file..brNOTE: if HISTFILE isn't set, no history file is used. This isdifferent from the original Korn shell, which uses \fB$HOME/.sh_history\fP;in future, pdksh may also use a default history file..ksh).\"}}}.\"{{{ HISTSIZE.ksh(.IP \fBHISTSIZE\fPThe number of commands normally stored for history, default 128..ksh).\"}}}.\"{{{ HOME.IP \fBHOME\fPThe default directory for the \fBcd\fP command and the valuesubstituted for an unqualified \fB~\fP (see Tilde Expansion below)..\"}}}.\"{{{ IFS.IP \fBIFS\fPInternal field separator, used during substitution and by the \fBread\fPcommand, to split values into distinct arguments; normally set tospace, tab and newline. See Substitution above for details..br\fBNote:\fP this parameter is not imported from the environmentwhen the shell is started..\"}}}.\"{{{ KSH_VERSION.ksh(.IP \fBKSH_VERSION\fPThe version of shell and the date the version was created (readonly).See also the version commands in Emacs Editing Modeand Vi Editing Mode sections, below..ksh).\"}}}.\"{{{ SH_VERSION.sh(.IP \fBSH_VERSION\fPThe version of shell and the date the version was created (readonly)..sh).\"}}}.\"{{{ LINENO.IP \fBLINENO\fPThe line number of the function or shell script that is currently beingexecuted..\"}}}.\"{{{ LINES.IP \fBLINES\fPSet to the number of lines on the terminal or window..\"Currently set to the \fBrows\fP value as reported by \fIstty\fP(1) if that.\"value is non-zero..\" todo: LINES variable.spNot implemented yet..\"}}}.\"{{{ MAIL.ksh(.IP \fBMAIL\fPIf set, the user will be informed of the arrival of mail in the namedfile. This parameter is ignored if the \fBMAILPATH\fP parameter is set..ksh).\"}}}.\"{{{ MAILCHECK.ksh(.IP \fBMAILCHECK\fPHow often, in seconds, the shell will check for mail in the file(s)specified by \fBMAIL\fP or \fBMAILPATH\fP. If 0, the shell checksbefore each prompt. The default is 600 (10 minutes)..ksh).\"}}}.\"{{{ MAILPATH.ksh(.IP \fBMAILPATH\fPA list of files to be checked for mail. The list is colon separated,and each file may be followed by a \fB?\fP and a message to be printedif new mail has arrived. Command, parameter and arithmetic substitution isperformed on the message, and, during substitution, the parameter \fB$_\fPcontains the name of the file.The default message is \fByou have mail in $_\fP..ksh).\"}}}.\"{{{ OLDPWD.IP \fBOLDPWD\fPThe previous working directory.Unset if \fBcd\fP has not successfully changed directories since theshell started, or if the shell doesn't know where it is..\"}}}.\"{{{ OPTARG.IP \fBOPTARG\fPWhen using \fBgetopts\fP, it contains the argument for a parsed option,if it requires one..\"}}}.\"{{{ OPTIND.IP \fBOPTIND\fPThe index of the last argument processed when using \fBgetopts\fP.Assigning 1 to this parameter causes \fBgetopts\fP toprocess arguments from the beginning the next time it is invoked..\"}}}.\"{{{ PATH.IP \fBPATH\fPA colon separated list of directories that are searched when looking
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -