Summary
When a heredoc with a trailing comment (e.g., <<-EOF # comment) is inside an indented block, shfmt duplicates the comment after EOF on each run. This is non-idempotent behavior.
Steps to reproduce
$ cat test.sh
#!/bin/bash
if true; then
cat <<-EOF # comment
content
EOF
fi
$ shfmt -w test.sh
$ cat test.sh
#!/bin/bash
if true; then
cat <<-EOF # comment
content
EOF
# comment
fi
$ shfmt -w test.sh
$ cat test.sh
#!/bin/bash
if true; then
cat <<-EOF # comment
content
EOF
# comment
# comment
fi
Each invocation adds another copy of the comment.
Environment
- shfmt version: v3.12.0
- OS: Linux (Fedora 42)
Related issues
Summary
When a heredoc with a trailing comment (e.g.,
<<-EOF # comment) is inside an indented block,shfmtduplicates the comment afterEOFon each run. This is non-idempotent behavior.Steps to reproduce
Each invocation adds another copy of the comment.
Environment
Related issues