Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heredoc_body skips lines before indented lines #216

Closed
osthomas opened this issue Sep 20, 2023 · 0 comments · Fixed by #217
Closed

heredoc_body skips lines before indented lines #216

osthomas opened this issue Sep 20, 2023 · 0 comments · Fixed by #217

Comments

@osthomas
Copy link

When indented lines occur in a heredoc after the first line, then all prior lines are not captured by heredoc_body. This happens for both spaces and tabs. Subsequent lines are okay if they are not indented at all.

Here are some examples:

image

cat <<EOF
    Correct
Correct
EOF

cat <<EOF
    Wrong
Wrong
    Correct
EOF

cat <<EOF
Wrong
    Correct
EOF

cat <<EOF
    Wrong
    Correct
Correct
EOF

cat <<EOF
   Wrong
  Wrong 2
 Correct
EOF

cat <<EOF
   Wrong
   Correct

EOF

cat <<EOF
   Wrong
   Correct

EOF

cat <<EOF
   Wrong
   Wrong
 
EOF

cat <<EOF
	Wrong
	Wrong 2
	Correct
EOF

And the tree:

(redirected_statement) ; [1:1 - 4:3]
 body: (command) ; [1:1 - 3]
  name: (command_name) ; [1:1 - 3]
   (word) ; [1:1 - 3]
 redirect: (heredoc_redirect) ; [1:5 - 4:3]
  (heredoc_start) ; [1:7 - 9]
  (heredoc_body) ; [2:5 - 4:0]
  (heredoc_end) ; [4:1 - 3]
(redirected_statement) ; [6:1 - 10:3]
 body: (command) ; [6:1 - 3]
  name: (command_name) ; [6:1 - 3]
   (word) ; [6:1 - 3]
 redirect: (heredoc_redirect) ; [6:5 - 10:3]
  (heredoc_start) ; [6:7 - 9]
  (heredoc_body) ; [9:5 - 10:0]
  (heredoc_end) ; [10:1 - 3]
(redirected_statement) ; [12:1 - 15:3]
 body: (command) ; [12:1 - 3]
  name: (command_name) ; [12:1 - 3]
   (word) ; [12:1 - 3]
 redirect: (heredoc_redirect) ; [12:5 - 15:3]
  (heredoc_start) ; [12:7 - 9]
  (heredoc_body) ; [14:5 - 15:0]
  (heredoc_end) ; [15:1 - 3]
(redirected_statement) ; [17:1 - 21:3]
 body: (command) ; [17:1 - 3]
  name: (command_name) ; [17:1 - 3]
   (word) ; [17:1 - 3]
 redirect: (heredoc_redirect) ; [17:5 - 21:3]
  (heredoc_start) ; [17:7 - 9]
  (heredoc_body) ; [19:5 - 21:0]
  (heredoc_end) ; [21:1 - 3]
(redirected_statement) ; [23:1 - 27:3]
 body: (command) ; [23:1 - 3]
  name: (command_name) ; [23:1 - 3]
   (word) ; [23:1 - 3]
 redirect: (heredoc_redirect) ; [23:5 - 27:3]
  (heredoc_start) ; [23:7 - 9]
  (heredoc_body) ; [26:2 - 27:0]
  (heredoc_end) ; [27:1 - 3]
(redirected_statement) ; [29:1 - 33:3]
 body: (command) ; [29:1 - 3]
  name: (command_name) ; [29:1 - 3]
   (word) ; [29:1 - 3]
 redirect: (heredoc_redirect) ; [29:5 - 33:3]
  (heredoc_start) ; [29:7 - 9]
  (heredoc_body) ; [31:4 - 33:0]
  (heredoc_end) ; [33:1 - 3]
(redirected_statement) ; [35:1 - 39:3]
 body: (command) ; [35:1 - 3]
  name: (command_name) ; [35:1 - 3]
   (word) ; [35:1 - 3]
 redirect: (heredoc_redirect) ; [35:5 - 39:3]
  (heredoc_start) ; [35:7 - 9]
  (heredoc_body) ; [37:4 - 39:0]
  (heredoc_end) ; [39:1 - 3]
(redirected_statement) ; [41:1 - 45:3]
 body: (command) ; [41:1 - 3]
  name: (command_name) ; [41:1 - 3]
   (word) ; [41:1 - 3]
 redirect: (heredoc_redirect) ; [41:5 - 45:3]
  (heredoc_start) ; [41:7 - 9]
  (heredoc_body) ; [45:1 - 0]
  (heredoc_end) ; [45:1 - 3]
(redirected_statement) ; [47:1 - 51:3]
 body: (command) ; [47:1 - 3]
  name: (command_name) ; [47:1 - 3]
   (word) ; [47:1 - 3]
 redirect: (heredoc_redirect) ; [47:5 - 51:3]
  (heredoc_start) ; [47:7 - 9]
  (heredoc_body) ; [50:2 - 51:0]
  (heredoc_end) ; [51:1 - 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant