102 lines
3.8 KiB
HTML
102 lines
3.8 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=utf-8">
|
|
<title>Parameters</title>
|
|
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</HEAD>
|
|
<body bgcolor="#FFFFFF">
|
|
<!-- Java sync-link -->
|
|
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
|
|
|
|
|
|
|
<h2>Parameters</h2>
|
|
|
|
<p>A parameter is used to store data. You can access the value of a
|
|
parameter by preceding its name with a dollar sign
|
|
(<strong>$</strong>) and surrounding the name with brackets
|
|
(<strong>{ }</strong>). The brackets are optional when the name is
|
|
a single digit, is a special parameter, or is a single identifier.
|
|
See <a href="paramexp.htm">"Parameter expansion"</a> for more
|
|
information about expanding the value of a parameter.</p>
|
|
|
|
<p><strong>Positional parameters</strong></p>
|
|
|
|
<p>A positional parameter is a decimal number starting from one.
|
|
Initially, <strong>qsh</strong> sets the positional parameters to
|
|
the command line arguments that follow the name of the shell
|
|
script. The positional parameters are temporarily replaced when a
|
|
shell function is called and can be reassigned using the <a href=
|
|
"set.htm">set</a> and <a href="shift.htm">shift</a> utilities.</p>
|
|
|
|
<p><strong>Special parameters</strong></p>
|
|
|
|
<p>A special parameter is denoted by one of these special
|
|
characters:</p>
|
|
|
|
<dl>
|
|
<dt><strong>* (Positional parameters)</strong></dt>
|
|
|
|
<dd>(Asterisk) Expands to the positional parameters, starting from
|
|
one. When the expansion occurs within a string with quotation marks, it
|
|
expands to a single field with the value of each parameter
|
|
separated by the first character of the <strong>IFS</strong>
|
|
variable, or by a <space> if <strong>IFS</strong> is
|
|
unset.<p></dd>
|
|
|
|
<dt><strong>@ (Positional parameters)</strong></dt>
|
|
|
|
<dd>(At sign) Expands to the positional parameters, starting from
|
|
one. When the expansion occurs within quotation marks, each
|
|
positional parameter expands as a separate argument. If there are
|
|
no positional parameters, the expansion of <strong>@</strong>
|
|
generates zero arguments, even when <strong>@</strong> is
|
|
in quotation marks.<p></dd>
|
|
|
|
<dt><strong># (Number of positional parameters)</strong></dt>
|
|
|
|
<dd>(Number sign) Expands to the decimal number of positional
|
|
parameters. It is initially set to the number of arguments when
|
|
<strong>qsh</strong> is invoked. It can be changed by the <a href=
|
|
"set.htm">set</a>, <a href="shift.htm">shift</a>, or <a href=
|
|
"dot.htm">dot</a> utilities or by calling a function.<p></dd>
|
|
|
|
<dt><strong>? (Exit status)</strong></dt>
|
|
|
|
<dd>(Question mark) Expands to the decimal exit status of the most
|
|
recent command. A value of zero indicates successful completion. A
|
|
non-zero value indicates an error. A command ended by a signal
|
|
number has an exit status of 128 plus the signal number.<p></dd>
|
|
|
|
<dt><strong>- (Option flags)</strong></dt>
|
|
|
|
<dd>(Minus) Expands to the current option flags (the single-letter
|
|
option names concatenated into a string) as specified when <strong>
|
|
qsh</strong> is invoked, by <a href="set.htm">set</a>, or
|
|
implicitly by <strong>qsh</strong>.<p></dd>
|
|
|
|
<dt><strong>$ (Process ID of current shell)</strong></dt>
|
|
|
|
<dd>(Dollar sign) Expands to the decimal process ID of the current
|
|
shell. A subshell retains the same value of <strong>$</strong> as
|
|
the current shell even if the subshell is running in a different
|
|
process.<p></dd>
|
|
|
|
<dt><strong>! (Background process ID)</strong></dt>
|
|
|
|
<dd>(Exclamation mark) Expands to the decimal process ID of the
|
|
most recent background command run from the current shell. For a
|
|
pipeline, the process ID is that of the last command in the
|
|
pipeline.<p></dd>
|
|
|
|
<dt><strong>0 (Name of shell script)</strong></dt>
|
|
|
|
<dd>(Zero) Expands to the name of the shell or shell script.<p></dd>
|
|
</dl>
|
|
</body>
|
|
</html>
|
|
|