From cf35a8e3a5ee724f12f13175d81d89b8d74c997c Mon Sep 17 00:00:00 2001 From: axel Date: Sun, 4 Jun 2006 19:42:03 +1000 Subject: [PATCH] Add documentation about support for negative indices darcs-hash:20060604094203-ac50b-6cf671235549eb79d3464a15398b6511057dedde.gz --- doc_src/doc.hdr | 4 ++++ doc_src/set.txt | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc_src/doc.hdr b/doc_src/doc.hdr index 17ff4e3e1..bdaebb48a 100644 --- a/doc_src/doc.hdr +++ b/doc_src/doc.hdr @@ -747,6 +747,10 @@ set -e smurf[1] echo $smurf +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 The user can change the settings of \c fish by changing the values of diff --git a/doc_src/set.txt b/doc_src/set.txt index bc03c1e13..2a8b8d9f4 100644 --- a/doc_src/set.txt +++ b/doc_src/set.txt @@ -32,7 +32,12 @@ If the variable name is one or more array elements, such as PATH[1 3 7], only those array elements specified will be changed. When array indices are specified to set, multiple arguments may be used to specify additional indexes, e.g. set PATH[1] -PATH[4] /bin /sbin. +PATH[4] /bin /sbin. 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 not explicitly set to be either universal, global or local, but has been previously defined, the previos variable scope is used.