Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    It may be worth noting that positional parameters differ from bash arrays in some key features. For example, they do not support sparse arrays, and since sh doesn't have slicing parameter expansion, you can't access sublists like "${@:2:4}". To be sure, I see the similarities, but I don't regard positional parameters as an array per se. Commented Jan 22, 2016 at 16:37
  • @kojiro, to some extent, I'd say it's the contrary, "$@" acts like an array (like the arrays of csh, rc, zsh, fish, yash...), it's more the Korn/bash "arrays" that are not really arrays, but some form of associative arrays with keys limited to positive integers (they also have indices starting at 0 instead of 1 like in all other shells with arrays and "$@"). Shells that have support for slicing can slice $@ just the same (with ksh93/bash awkwardly adding $0 to the positional parameters when you slice "$@"). Commented Oct 23, 2017 at 6:57
  • 1
    /bin/sh continues to give me Syntax error: "(" unexpected for arrays Commented Jul 19, 2021 at 22:23