Skip to content

Commit

Permalink
Fix subshells nested in var expansion (#7)
Browse files Browse the repository at this point in the history
The pretty printer printed it as $(()), an arithmetic expansion.
  • Loading branch information
BolunThompson authored Jan 3, 2025
1 parent ecb26a0 commit 13a43e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shasta/ast_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,14 @@ def json(self):

def pretty(self, quote_mode=UNQUOTED):
param = self.node
return "$(" + param.pretty() + ")"
body = param.pretty()
# to handle $( () )
try:
if body[0] == "(" and body[-1] == ")":
body = f" {body} "
except IndexError:
pass
return "$(" + body + ")"

class AssignNode(AstNode):
var: str
Expand Down

0 comments on commit 13a43e4

Please sign in to comment.