help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does ${x[@]} have to be written as is?


From: Peng Yu
Subject: Why does ${x[@]} have to be written as is?
Date: Sun, 9 May 2021 18:26:00 -0500

Hi

Things like `${x [@] }` are not legitimate. Why not allowing such a
case and treat it the same as ${x[@]}?

I can understand that `VAR=val cmd` should not be written as `VAR =
val cmd` as there is a different meaning of the 2nd form.

But for the case like "${x[@]}", it seems that spaces can be
introduced in "${...}" without hurting anything.

Since I don't see ${x[@]} in the bison code, I assume it is parsed
completely by the yylex(). Is it so?

https://git.savannah.gnu.org/cgit/bash.git/tree/parse.y#n381

yylex() seems to be too complicated. By allowing spaces in ${...},
would it possible to convert some of the logic in yylex() into the
bison grammar, so that the coupling of the lexer and the parser be
reduced thus making the code in parse.y easier to understand and
maintain?

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]