[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] fix printing command after group with heredoc
From: |
Grisha Levit |
Subject: |
[PATCH] fix printing command after group with heredoc |
Date: |
Thu, 29 Jun 2023 04:05:50 -0400 |
If the last redirection list in a group / subshell / substitution has
a heredoc and the following connector is a semicolon, the connector is
incorrectly skipped over.
This happens only outside of function definitions, so I think it's an
issue only for pretty-print mode.
bash --pretty-print <<<$'(:<<EOF\nEOF\n);:'
( : <<EOF
EOF
) :
While this patch forces the semicolon to be printed, I'm definitely
seeing the merit of Martin's point re: printing with newlines only.
---
print_cmd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/print_cmd.c b/print_cmd.c
index a38c1b3a..0bed2968 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -298,10 +298,9 @@ make_command_string_internal (COMMAND *command)
was_newline = deferred_heredocs == 0 && was_heredoc == 0 && c == '\n';
if (deferred_heredocs == 0)
{
- if (was_heredoc == 0)
+ if (was_heredoc == 0 || (inside_function_def == 0 && c == ';'))
cprintf ("%s", s); /* inside_function_def? */
- else
- was_heredoc = 0;
+ was_heredoc = 0;
}
else
/* print_deferred_heredocs special-cases `;' */
--
2.41.0
- [PATCH] fix printing command after group with heredoc,
Grisha Levit <=