shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Heredoc terminated after process substitution parenthesis should be flagged

Open ShamrockLee opened this issue 6 months ago • 0 comments

Terminating the Bash here document after the termination of process substitution silently passes ShellCheck.

Problematic code:

cat <(cat <<EOF)
Hello, world!
EOF

Correct code:

cat <(cat <<EOF
Hello, world!
EOF
)

Bash tolerates the problematic code and behave the same as the correct code, plus a line of warning message:

bash: warning: command substitution: 1 unterminated here-document

Due to this behavior of Bash, such anti-pattern is hard to locate without going through the standard error line-by-line. Flagging it as a SC1044 or its own rule will be very helpful.

ShamrockLee avatar May 03 '25 20:05 ShamrockLee