0

If I run set -A in zsh to view all arrays, the first two are:

awesomeprompt% set -A
'*'=(  )
@=(  )

What are the '*' and @ arrays for?

1 Answer 1

0

Found the answer on the zshparam page:

The parameters *, @ and argv are arrays containing all the positional parameters; thus '$argv[n]', etc., is equivalent to simply '$n'.

So you can do:

awesomeprompt% function testme() { echo $*[1] }
awesomeprompt% testme a
a
awesomeprompt% function testme() { echo $@[1] }
awesomeprompt% testme a
a
1
  • I guess in hindsight they are more recognizable with the dollar sign: $@, $*.
    – xdhmoore
    Commented Aug 20, 2023 at 22:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .