137 lines
4.4 KiB
HTML
137 lines
4.4 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>declare - Declare variables and set attributes</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>
|
||
|
|
||
|
<p>
|
||
|
|
||
|
<h2>declare - Declare variables and set attributes</h2>
|
||
|
|
||
|
<strong>Synopsis</strong>
|
||
|
</p>
|
||
|
|
||
|
<p><strong>declare [ -Eilrux ]</strong> <em>name</em> <strong>[</strong><em>=value</em><strong>]</strong> ...</p>
|
||
|
<p><strong>declare [ +Eilrux ]</strong> <em>name</em> <strong>[</strong><em>=value</em><strong>]</strong> ...</p>
|
||
|
<p><strong>declare -fF [</strong> <em>name ...</em> <strong>]</strong></p>
|
||
|
<p><strong>declare -p </strong> <em>name ...</em></p>
|
||
|
<p><strong>declare</strong></p>
|
||
|
|
||
|
<p><strong>Description</strong></p>
|
||
|
|
||
|
<p>The <strong>declare</strong> utility declares variables, assigns values to variables,
|
||
|
sets or unsets attributes for variables, and displays the definitions for
|
||
|
<a href="cmpdcmds.htm#functions">shell functions</a>. If used in a shell function,
|
||
|
<strong>declare</strong> makes the variable <em>name</em> local to the function.
|
||
|
</p>
|
||
|
|
||
|
<p>In the first synopsis form, <strong>declare</strong> declares a variable <em>name</em>
|
||
|
and optionally assigns it the specified <em>value</em>. If an option is specified,
|
||
|
the corresponding attribute is turned on for the variable.</p>
|
||
|
|
||
|
<p>In the second synopsis form, <strong>declare</strong> declares a variable <em>name</em>
|
||
|
and optionally assigns it the specified <em>value</em>. If an option is specified,
|
||
|
the corresponding attribute is turned off for the variable.</p>
|
||
|
|
||
|
<p>In the third synopsis form, <strong>declare</strong> displays the names and definitions
|
||
|
for all shell functions if no <em>names</em> are specified or the shell functions specified
|
||
|
by <em>name</em>.</p>
|
||
|
|
||
|
<p>In the fourth synopsis form, <strong>declare</strong> displays the attributes and value
|
||
|
of the variables specified by <em>name</em> in a re-enterable format.</p>
|
||
|
|
||
|
<p>In the fifth synopsis form, <strong>declare</strong> displays the names and values
|
||
|
of all variables.</p>
|
||
|
|
||
|
<p><strong>Options</strong></p>
|
||
|
<dl>
|
||
|
<dt><strong>-E</strong></dt>
|
||
|
|
||
|
<dd>Set the floating point attribute for the variable. On assignments to the
|
||
|
variable the value is evaluated as a floating point number.</dd>
|
||
|
|
||
|
<dt><strong>-f</strong></dt>
|
||
|
|
||
|
<dd>Display the names and definitions of shell functions.</dd>
|
||
|
|
||
|
<dt><strong>-F</strong></dt>
|
||
|
|
||
|
<dd>Display the names of shell functions.</dd>
|
||
|
|
||
|
<dt><strong>-i</strong></dt>
|
||
|
|
||
|
<dd>Set the integer attribute for the variable. On assignments to the
|
||
|
variable the value is evaluated as an integer number.</dd>
|
||
|
|
||
|
<dt><strong>-l</strong></dt>
|
||
|
|
||
|
<dd>Set the lowercase attribute for the variable. On assignments to the
|
||
|
variable the value is set to lowercase characters.</dd>
|
||
|
|
||
|
<dt><strong>-p</strong></dt>
|
||
|
|
||
|
<dd>Display each variable in a re-enterable format.</dd>
|
||
|
|
||
|
<dt><strong>-r</strong></dt>
|
||
|
|
||
|
<dd>Set the read-only attribute for the variable. The variable cannot have its value
|
||
|
changed by a subsequent assignment and cannot be unset. If a <em>value</em>
|
||
|
is also specified, the value of the variable is updated before setting
|
||
|
the read-only attribute.</dd>
|
||
|
|
||
|
<dt><strong>-u</strong></dt>
|
||
|
|
||
|
<dd>Set the uppercase attribute for the variable. On assignments to the
|
||
|
variable the value is set to uppercase characters.</dd>
|
||
|
|
||
|
<dt><strong>-x</strong></dt>
|
||
|
|
||
|
<dd>Set the export attribute for the variable. The variable is automatically placed
|
||
|
in the environment of subsequently executed commands.</dd>
|
||
|
|
||
|
</dl>
|
||
|
|
||
|
<p><strong>Operands</strong></p>
|
||
|
|
||
|
<p>Each <em>name</em> must be a valid <a href="variable.htm">shell variable</a> name.</p>
|
||
|
|
||
|
<p><strong>Exit Status</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li>0 when successful</li>
|
||
|
|
||
|
<li>>0 when unsuccessful</li>
|
||
|
</ul>
|
||
|
|
||
|
<p><strong>Related information</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="export.htm">export - Set export attribute for
|
||
|
variables</a></li>
|
||
|
|
||
|
<li><a href="let.htm">let - Evaluate arithmetic expression</a></li>
|
||
|
|
||
|
<li><a href="local.htm">local - Assign a local variable in a
|
||
|
function</a></li>
|
||
|
|
||
|
<li><a href="readonly.htm">readonly - Set read-only attribute for variables</a></li>
|
||
|
|
||
|
<li><a href="set.htm">set - Set or unset options and positional
|
||
|
parameters</a></li>
|
||
|
|
||
|
<li><a href="unset.htm">unset - Unset values of variables and
|
||
|
functions</a></li>
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|