Skip to content

Commit adf4837

Browse files
committed
- Add support for using heredoc
1 parent 7153ce9 commit adf4837

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

lib/bashly/extensions/array.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def indent(offset)
1010
heredoc_marker = nil if /^#{heredoc_marker}\n?$/.match?(line)
1111
line
1212
else
13-
heredoc_marker = $1 if line =~ /<<-?(\w+)\n?$/
13+
heredoc_marker = $1 if line =~ /<<-?\s*(\w[\w\d]*)/
1414
"#{indentation}#{line}"
1515
end
1616
end

spec/approvals/fixtures/heredoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ also unindented
1414

1515
3 indentations with empty line above
1616
also unindented
17+
writing to file:
18+
0 indentation
19+
1 indentation
20+
1 indentation
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0 indentation
2+
1 indentation
3+
1 indentation

spec/fixtures/workspaces/heredoc/src/root_command.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ cat <<-SECOND_BLOCK
1616
SECOND_BLOCK
1717

1818
echo also unindented
19+
20+
echo "writing to file:"
21+
cat << EOF > output.txt
22+
0 indentation
23+
1 indentation
24+
1 indentation
25+
EOF
26+
27+
cat output.txt

0 commit comments

Comments
 (0)