Add documentation about support for negative indices

darcs-hash:20060604094203-ac50b-6cf671235549eb79d3464a15398b6511057dedde.gz
This commit is contained in:
axel 2006-06-04 19:42:03 +10:00
parent e7e3e8ee74
commit cf35a8e3a5
2 changed files with 10 additions and 1 deletions

View file

@ -747,6 +747,10 @@ set -e smurf[1]
echo $smurf echo $smurf
</pre> </pre>
If you specify a negative index when expanding or assigning to an
array variable, the index will be calculated from the end of the
array. For example, the index -1 means the last index of an array.
\subsection variables-special Special variables \subsection variables-special Special variables
The user can change the settings of \c fish by changing the values of The user can change the settings of \c fish by changing the values of

View file

@ -32,7 +32,12 @@ If the variable name is one or more array elements, such as
<code>PATH[1 3 7]</code>, only those array elements specified will be <code>PATH[1 3 7]</code>, only those array elements specified will be
changed. When array indices are specified to set, multiple arguments changed. When array indices are specified to set, multiple arguments
may be used to specify additional indexes, e.g. <code>set PATH[1] may be used to specify additional indexes, e.g. <code>set PATH[1]
PATH[4] /bin /sbin</code>. PATH[4] /bin /sbin</code>. If you specify a negative index when
expanding or assigning to an array variable, the index will be
calculated from the end of the array. For example, the index -1 means
the last index of an array.
-# If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed. -# If a variable is explicitly set to either universal, global or local, that setting will be honored. If a variable of the same name exists in a different scope, that variable will not be changed.
-# If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previos variable scope is used. -# If a variable is not explicitly set to be either universal, global or local, but has been previously defined, the previos variable scope is used.