Skip to content

Commit 9e98979

Browse files
committed
Prevent specific while loop to be recognized as heredoc
This change should fix issues with while loops formatted the following way: while read -r thing; do echo "$thing done" done <<< $filename beautysh.py was parsing that `<<< $filename` as a heredoc delimiter, enabling a heredoc paragraph that was never being closed. And that was the cause for the error message of those indent/outdent mismatch: the indentation was the same as the one in `done <<< $filename` till the end of file. Now, before enabling heredoc, we double check if it really isn't a while case. Ref: #23
1 parent c66c2f8 commit 9e98979

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

beautysh/beautysh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def beautify_string(self, data, path=''):
7777
re.search(r'<<', test_record)):
7878
in_here_doc = False
7979
else: # not in here doc
80-
if(re.search(r'<<-?', test_record)):
80+
if(re.search(r'<<-?', test_record)) and not (re.search(r'done.*<<<', test_record)):
8181
here_string = re.sub(
8282
r'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', r'\1',
8383
stripped_record, 1)

0 commit comments

Comments
 (0)