shfmt is incorrectly reporting an "unclosed here-document" error for a bash script that uses the <<- syntax with a tab-indented closing delimiter. This syntax should be valid according to bash heredoc documentation.
Script content (test.sh):
#!/bin/bash
main() {
bash <<-EXEC
uname -a
EXEC
}
main
Note: The closing EXEC and the content are indented with tabs, not spaces.
OS: Windows 11 Home Single Language 23H2 22631.3880
PowerShell: 5.1.22621.3880
VSCode: 1.92.1 (user setup)
Additional notes:
The script works correctly when executed.
The error occurs both when using shfmt directly and through the VSCode extension.
This issue also affects the VSCode extension shell-format, which uses shfmt as a dependency. This suggests the problem has a wider impact on the ecosystem of shell scripting tools.
Expected behavior:
shfmt should recognize the tab-indented closing delimiter and content as valid when using the <<- syntax and not report an "unclosed here-document" error.
Steps to reproduce:
Create a file named test.sh with the content provided above.
shfmt is incorrectly reporting an "unclosed here-document" error for a bash script that uses the <<- syntax with a tab-indented closing delimiter. This syntax should be valid according to bash heredoc documentation.
Script content (
test.sh
):Note: The closing
EXEC
and the content are indented with tabs, not spaces.Error message:
Environment:
Additional notes:
Expected behavior: shfmt should recognize the tab-indented closing delimiter and content as valid when using the <<- syntax and not report an "unclosed here-document" error.
Steps to reproduce:
shfmt -ln bash -l -w "path\to\test.sh"
Additional readings:
Please let me know if you need any additional information or if there's a workaround for this issue. Thank you for your attention to this matter.