I found references for parameter expansion, but none of them explain what $^@ does. From context, I think it's used to expand e.g. ~/$^@ into ~/$1 ~/$2 ..., but I'm not sure, and I can't find any confirmation. In addition to an explanation, I'd appreciate knowing what this expansion is called, and a link to documentation about it if possible. Thanks!

EDIT: I've been informed this might be particular to zsh. If anyone has further information, please let me know.

  • 1
    Was this by any chance a zsh script? That shell would be able to do exactly that, and it means exactly what you have described, it appends a string to all elements of an array. I'm not turning this into a proper answer as I don't know for sure what shell the script was written for (there may be other shells that does something similar, Stéphane would know).
    – Kusalananda
    Nov 18, 2021 at 20:07
  • You should provide the real code. Nov 18, 2021 at 20:18
  • 1
    Yes, it's zsh. I didn't know that was relevant. Thanks.
    – mangoduck
    Nov 18, 2021 at 20:24
  • I mean, the code can be as simple as echo ~/$^@
    – mangoduck
    Nov 18, 2021 at 20:26
  • But if you are not using zsh then echo ~/$^@ doesn't do anything. Nov 18, 2021 at 20:31

1 Answer 1


In the zsh shell, foo${^array}bar, where array is an array, like (a b c), would expand to fooabar, foobbar, and foocbar (like a brace expansion would expand) instead of to the strings fooa, b, and cbar:

$ array=(a b c)
$ print -rC1 foo${^array}bar
$ print -rC1 foo${array}bar

In the code that you quote, this is used to append ~/ (the pathname of the user's home directory) to each element of the list of positional parameters:

$ set -- a b c "bumble bee"
$ print -rC1 ~/$^@
/home/myself/bumble bee

~/$^@ is the same as ~/${^@}. $@ or ${@} is the list of positional parameters (commonly the arguments given to the current script or shell function, or the strings set with the set built-in utility, as shown above).

Search the zshall manual for RC_EXPAND_PARAM. The expansion may originally come from the rc shell.

  • That's what rc does by default, and see the ^ operator there as well. But the behaviour is different when joining two arrays. Compare rc -c 'a=(a b); echo $a^X' with zsh -c 'a=(a b); echo ${^a}X' and rc -c 'a=(a b); echo $a^$a' vs zsh -c 'a=(a b); echo $^a$^a'. The behaviour of zsh -o rcexpandparam is more like the default behaviour of fish (fish -c 'set a a b; echo $a$a') Nov 19, 2021 at 17:13

You must log in to answer this question.

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