Skip to content

Formatting files using shfmt results in an empty file when shfmt can't parse the file #1162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chris-reeves opened this issue May 14, 2024 · 0 comments · Fixed by #1163
Closed

Comments

@chris-reeves
Copy link
Contributor

chris-reeves commented May 14, 2024

When formatting is enabled and run against a file that shfmt can't parse, the contents are replaced with an empty file. This is a result of improper handling when shfmt returns a non-zero exit status.

Originally reported by @David-Else in #1136 (comment)

chris-reeves added a commit to chris-reeves/bash-language-server that referenced this issue May 14, 2024
Non-zero exist statuses from `shfmt` weren't checked for or handled. As
a result the (empty) output from `shfmt` was returned as the formatted
document. An exception is now thrown when a non-zero exit status is
encountered.

Fixes bash-lsp#1162
chris-reeves added a commit to chris-reeves/bash-language-server that referenced this issue May 14, 2024
Non-zero exist statuses from `shfmt` weren't checked for or handled. As
a result the (empty) output from `shfmt` was returned as the formatted
document. An exception is now thrown when a non-zero exit status is
encountered.

Fixes bash-lsp#1162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant