Skip to content

Parser: AssignmentWord inside rule cmd_suffix #262

Answered by reubeno
39555 asked this question in Q&A
Discussion options

You must be logged in to vote

I noticed that you have an AssignmentWord inside the cmd_suffix rule, so echo hello FOO=1 is parsed as CommandSuffix(Word, AssignmentWord). Is there any reason for this? I far as I know you can't set variables in the command suffix in Bash.

There's a specific set of built-ins that can (and need to) take assignments as suffix arguments, although the builtins implement the assignment themselves. Notably, this includes declare, local, export, et al. It's really most important for handling array assignments.

From the bash reference manual:

Assignment statements may also appear as arguments to the alias, declare, typeset, export, readonly, and local builtin commands (declaration commands).

C…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by 39555
Comment options

You must be logged in to vote
5 replies
@39555
Comment options

@39555
Comment options

@reubeno
Comment options

@39555
Comment options

@39555
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #261 on November 06, 2024 18:13.