( Shell Parameters

Info Catalog ( Shell Functions ( Basic Shell Features ( Shell Expansions
 3.4 Shell Parameters


* Positional Parameters       The shell's command-line arguments.
* Special Parameters          Parameters denoted by special characters.
    A PARAMETER is an entity that stores values.  It can be a `name', a
 number, or one of the special characters listed below.  A VARIABLE is a
 parameter denoted by a `name'.  A variable has a VALUE and zero or more
 ATTRIBUTES.  Attributes are assigned using the `declare' builtin command
 (see the description of the `declare' builtin in  Bash Builtins).
    A parameter is set if it has been assigned a value.  The null string
 is a valid value.  Once a variable is set, it may be unset only by using
 the `unset' builtin command.
    A variable may be assigned to by a statement of the form
    If VALUE is not given, the variable is assigned the null string.  All
 VALUEs undergo tilde expansion, parameter and variable expansion,
 command substitution, arithmetic expansion, and quote removal (detailed
 below).  If the variable has its `integer' attribute set, then VALUE is
 evaluated as an arithmetic expression even if the `$((...))' expansion
 is not used ( Arithmetic Expansion).  Word splitting is not
 performed, with the exception of `"$@"' as explained below.  Filename
 expansion is not performed.  Assignment statements may also appear as
 arguments to the `alias', `declare', `typeset', `export', `readonly',
 and `local' builtin commands.  When in POSIX mode ( Bash POSIX
 Mode), these builtins may appear in a command after one or more
 instances of the `command' builtin and retain these assignment
 statement properties.
    In the context where an assignment statement is assigning a value to
 a shell variable or array index ( Arrays), the `+=' operator can
 be used to append to or add to the variable's previous value.  When
 `+=' is applied to a variable for which the INTEGER attribute has been
 set, VALUE is evaluated as an arithmetic expression and added to the
 variable's current value, which is also evaluated.  When `+=' is
 applied to an array variable using compound assignment (
 Arrays), the variable's value is not unset (as it is when using `='),
 and new values are appended to the array beginning at one greater than
 the array's maximum index (for indexed arrays),  or added as additional
 key-value pairs in an associative array.  When applied to a
 string-valued variable, VALUE is expanded and appended to the
 variable's value.
    A variable can be assigned the NAMEREF attribute using the `-n'
 option to the \fBdeclare\fP or \fBlocal\fP builtin commands ( Bash
 Builtins) to create a NAMEREF, or a reference to another variable.
 This allows variables to be manipulated indirectly.  Whenever the
 nameref variable is referenced or assigned to, the operation is
 actually performed on the variable specified by the nameref variable's
 value.  A nameref is commonly used within shell functions to refer to a
 variable whose name is passed as an argument to the function.  For
 instance, if a variable name is passed to a shell function as its first
 argument, running
      declare -n ref=$1
    inside the function creates a nameref variable REF whose value is
 the variable name passed as the first argument.  References and
 assignments to REF are treated as references and assignments to the
 variable whose name was passed as `$1'.
    If the control variable in a `for' loop has the nameref attribute,
 the list of words can be a list of shell variables, and a name reference
 will be established for each word in the list, in turn, when the loop is
 executed.  Array variables cannot be given the `-n' attribute.
 However, nameref variables can reference array variables and subscripted
 array variables.  Namerefs can be unset using the `-n' option to the
 `unset' builtin ( Bourne Shell Builtins).  Otherwise, if `unset'
 is executed with the name of a nameref variable as an argument, the
 variable referenced by the nameref variable will be unset.
Info Catalog ( Shell Functions ( Basic Shell Features ( Shell Expansions
automatically generated byinfo2html