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
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.
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
Create a Bash script with the following content:
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:
Issues:
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.
Expected Output
The correctly formatted code should be:
The text was updated successfully, but these errors were encountered: