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.

3
  • git.savannah.gnu.org/cgit/bash.git/tree/parse.y#n5302 "A word is an assignment if it appears at the beginning of a simple command, or after another assignment word. This is context-dependent, so it cannot be handled in the grammar." So the parser can't handle ( like it would if it appeared elsewhere, and leaves it to the next level, which may barf on something that isn't a name. Commented Mar 16, 2020 at 10:09
  • Observation: use set -x and see the difference between declare -a array=( B C ), declare -a "array=( B C )", declare -a "array=(" B C ")" and similar variants. Commented Mar 16, 2020 at 10:17
  • @KamilMaciorowski Yes, this is what I intended with the last sentence in the question. @muru The fact that information is in a comment in the bash implementation sounds like it was worth asking this question :) ...I now get that the assignment is not recognised as such since it is not at the beginning of a simple command, but this is somehow expected, isn't it? I mean, what we call assignment is indeed an argument of declare or is it wrong to think in this way? Still I do not get the difference between line 4 and line 9. Commented Mar 16, 2020 at 10:44