From 9e98979087f0923ae222770d80fb25728c6914c2 Mon Sep 17 00:00:00 2001 From: streambinder Date: Tue, 20 Feb 2018 10:14:19 +0100 Subject: [PATCH] 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: https://github.com/bemeurer/beautysh/issues/23 --- beautysh/beautysh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beautysh/beautysh.py b/beautysh/beautysh.py index ca1b788..9a81238 100755 --- a/beautysh/beautysh.py +++ b/beautysh/beautysh.py @@ -77,7 +77,7 @@ def beautify_string(self, data, path=''): re.search(r'<<', test_record)): in_here_doc = False else: # not in here doc - if(re.search(r'<<-?', test_record)): + if(re.search(r'<<-?', test_record)) and not (re.search(r'done.*<<<', test_record)): here_string = re.sub( r'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', r'\1', stripped_record, 1)