From 22f794125fd5f7adbdf7c77458f08c4f421f007c Mon Sep 17 00:00:00 2001 From: santpent <44591078+santpent@users.noreply.github.com> Date: Fri, 2 Nov 2018 12:24:52 +0000 Subject: [PATCH] add command substition indexing examples (#5303) * add command substition indexing examples following from issue #243 * Update index.hdr.in --- doc_src/index.hdr.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index d3eb664b2..12eeeb994 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -671,8 +671,19 @@ set n -3 echo $PATH[$n..-1] \endfish -Note that variables can be used as indices for expansion of variables, but not command substitution. +Variables can be used as indices for expansion of variables, like so: +\fish +set index 2 +set letters a b c d +echo $letters[$index] # returns 'b' +\endfish +However using variables as indices for command substitution is currently not supported, so +\fish +echo (seq 5)[$index] # This won't work +set sequence (seq 5) # It needs to be written on two lines like this. +echo $sequence[$index] # returns '2' +\endfish \subsection expand-home Home directory expansion