Skip to content

Commit

Permalink
Merge pull request #18 from jesselang/bugfix/indent-command-with-heredoc
Browse files Browse the repository at this point in the history
Indent the command that starts a heredoc
  • Loading branch information
lovesegfault authored Oct 23, 2017
2 parents c9dfa34 + 554c66d commit 9fa3c1c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions beautysh/beautysh.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,20 @@ def beautify_string(self, data, path=''):
test_record = re.sub(r'\\.', '', test_record)
# remove '#' comments
test_record = re.sub(r'(\A|\s)(#.*)', '', test_record, 1)
if(not in_here_doc):
if(re.search(r'<<-?', test_record)):
here_string = re.sub(
r'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', r'\1',
stripped_record, 1)
in_here_doc = (len(here_string) > 0)

if(in_here_doc): # pass on with no changes
output.append(record)
# now test for here-doc termination string
if(re.search(here_string, test_record) and not
re.search(r'<<', test_record)):
in_here_doc = False
else: # not in here doc
if(re.search(r'<<-?', test_record)):
here_string = re.sub(
r'.*<<-?\s*[\'|"]?([_|\w]+)[\'|"]?.*', r'\1',
stripped_record, 1)
in_here_doc = (len(here_string) > 0)

if(in_ext_quote):
if(re.search(ext_quote_string, test_record)):
# provide line after quotes
Expand Down

0 comments on commit 9fa3c1c

Please sign in to comment.