brace expansion and array subscripts?

Marc Chantreux <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <aGuYG8VvGeTlWLF1@prometheus>
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
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQQrhynLytp14smlCwy+er2aYc+1WAUCaGuYFgAKCRC+er2aYc+1
WIiWAPwMjjhsV7RsEIu1CHT4VtHzl0N6v9VbZhQ/OoXS0LNEAwD9G4zKwxHYuZkd
/HP9Ocz0Tv9S7NLj/hZtY9i8E0ttFwY=
=X3Tt
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.