From 6c05005f0f9acc75e7fe4df77a7fd09c0706eed6 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 19 Jun 2019 12:56:01 +0200 Subject: [PATCH] docs: Document indexing double-variable-expansion Fixes #5886. [ci skip] --- sphinx_doc_src/index.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sphinx_doc_src/index.rst b/sphinx_doc_src/index.rst index b9d80d7a5..63831cd16 100644 --- a/sphinx_doc_src/index.rst +++ b/sphinx_doc_src/index.rst @@ -969,6 +969,15 @@ However using variables as indices for command substitution is currently not sup set sequence (seq 5) # It needs to be written on two lines like this. echo $sequence[$index] # returns '2' +When using indirect variable expansion with multiple `$` (``$$name``), you have to give all indices up to the variable you want to slice:: + + > set -l list 1 2 3 4 5 + > set -l name list + > echo $$name[1] + 1 2 3 4 5 + > echo $$name[1..-1][1..3] # or $$name[1][1..3], since $name only has one element. + 1 2 3 + .. _expand-home: Home directory expansion