You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
syntax: Incorrectly Formats Bash Script with Heredoc and Subshell #1131
Bug Report: shfmt 3.10.0 (Linux ARM64) Incorrectly Formats Bash Script with Heredoc and Subshell
Summary
When using shfmt version 3.10.0 on Linux ARM64 to format a Bash script containing a heredoc (cat <<END) piped into a tee command with a subshell redirection (>(...)), the tool generates incorrect and broken code.
The resulting output does not preserve the original functionality and introduces syntax errors.
Environment
Tool: shfmt
Version: 3.10.0
Platform: Linux ARM64
Date: February 20, 2025
Steps to Reproduce
Create a Bash script with the following content:
#!/usr/bin/bashfunctionpayload() {
cat <<END | tee >( { echo here the payload ; cat ; } >&2 )Line : ${LINENO}END
}
cat -n <(payload)
Run shfmt on the script: shfmt -i 4 -w script.sh
Observe the output generated by shfmt.
Actual Output
The formatted code produced by shfmt is:
The heredoc (cat <<END) and the tee command with subshell redirection (>(...)) are incorrectly split across multiple lines.
The subshell >({ echo payload ; cat ; } >&2) is improperly indented and placed outside the intended pipeline structure.
The resulting code is syntactically incorrect and fails to execute as intended.
changed the title [-]Bug Report: shfmt 3.10.0 (Linux ARM64) Incorrectly Formats Bash Script with Heredoc and Subshell[/-][+]syntax: Incorrectly Formats Bash Script with Heredoc and Subshell[/+]on Mar 2, 2025
Activity
[-]Bug Report: shfmt 3.10.0 (Linux ARM64) Incorrectly Formats Bash Script with Heredoc and Subshell[/-][+]syntax: Incorrectly Formats Bash Script with Heredoc and Subshell[/+]