-
-
Notifications
You must be signed in to change notification settings - Fork 381
Closed
Description
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
}
mainNote: The closing EXEC and the content are indented with tabs, not spaces.
Error message:
PS C:\...> shfmt -ln bash -l -w "C:\...\test.sh"
C:\...\test.sh:4:7: unclosed here-document 'EXEC'
Environment:
- shfmt version: v3.8.0
- Go version: go1.23.0 windows/amd64
- 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.
- Run
shfmt -ln bash -l -w "path\to\test.sh" - Observe the "unclosed here-document" error.
Additional readings:
- GNU Docs about Here-documents
- Advanced Bash-Scripting Guide's chapter about Here-documents
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels