Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

brace expansion and array subscripts?



On Sun, Jul 06, 2025 at 12:13:23AM +0200, Vincent Lefevre wrote:
> ... like what the following does:
> 
> qaa% echo foo{{1..3},{5..7}}
> foo1 foo2 foo3 foo5 foo6 foo7
> But I would like to avoid the extra braces.

I didn't realized this was possible and really like it.
In the same scope: it would be nice to have a
setopt rcsubscripts (in the same spirit of rcquotes)
to enable spaces in array subscripts

a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

alphabet=( {a..z} )
# another thing that should be nice: get the index out of it:
# echo ${(kv)alphabet}

echo $alphabet[ 8 5 12 12 15 ]

# so the ranges could be used as well:

echo 5 first letters: $alphabet[ {1..5} ]

regards

-- 
Marc Chantreux

Attachment: signature.asc
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author