-
Notifications
You must be signed in to change notification settings - Fork 104
Open
Description
for the code as following
code = '''cat << EOF
abc
def
EOF'''
ret = bashlex.parse(code)
print(ret[0].dump())we got:
CommandNode(pos=(0, 9), parts=[
WordNode(pos=(0, 3), word='cat'),
RedirectNode(heredoc=
HeredocNode(pos=(10, 21), value='abc\ndef\nEOF'), output=
WordNode(pos=(6, 9), word='EOF'), pos=(4, 21), type='<<'),
])
that's fine so far.
but for the code:
code = '''function foo () {
cat << EOF
abc
def
EOF
}'''
ret = bashlex.parse(code)
print(ret[0].dump())we got:
FunctionNode(pos=(0, 40), parts=[
ReservedwordNode(pos=(0, 8), word='function'),
WordNode(pos=(9, 12), word='foo'),
ReservedwordNode(pos=(12, 13), word='('),
ReservedwordNode(pos=(13, 14), word=')'),
CompoundNode(list=[
ReservedwordNode(pos=(15, 16), word='{'),
ListNode(pos=(17, 39), parts=[
CommandNode(pos=(17, 26), parts=[
WordNode(pos=(17, 20), word='cat'),
RedirectNode(heredoc=
HeredocNode(pos=(31, 38), value='def\nEOF'), output=
WordNode(pos=(23, 26), word='EOF'), pos=(21, 26), type='<<'),
]),
OperatorNode(op='\n', pos=(26, 27)),
CommandNode(pos=(27, 30), parts=[
WordNode(pos=(27, 30), word='abc'),
]),
OperatorNode(op='\n', pos=(30, 39)),
]),
ReservedwordNode(pos=(39, 40), word='}'),
], pos=(15, 40)),
])
in this case, abc no longer a part of the heredoc, but came out as a standalone CommandNode.
Metadata
Metadata
Assignees
Labels
No labels