mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 23:22:46 +08:00
add command substition indexing examples (#5303)
* add command substition indexing examples following from issue #243 * Update index.hdr.in
This commit is contained in:
parent
9300ec55f0
commit
22f794125f
|
@ -671,8 +671,19 @@ set n -3
|
||||||
echo $PATH[$n..-1]
|
echo $PATH[$n..-1]
|
||||||
\endfish
|
\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
|
\subsection expand-home Home directory expansion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user