emacs-format-all-the-code icon indicating copy to clipboard operation
emacs-format-all-the-code copied to clipboard

Improve shell variant detection for shfmt

Open rolandmas opened this issue 2 years ago • 4 comments

This adds a suffix to the filename passed to shfmt so it can use the default settings stored in .editorconfig even for shell scripts without an extension.

rolandmas avatar Oct 19 '23 16:10 rolandmas

Thanks. A better approach is to always use -ln instead of using fake filenames.

lassik avatar Oct 20 '23 19:10 lassik

I can write the code.

lassik avatar Oct 20 '23 19:10 lassik

Wait, editorconfig. Isn't it supposed to be based on filename patterns only? So if you want to use editoconfig settings for foo, you have to write a [foo] section in the .editorconfig file?

lassik avatar Oct 20 '23 19:10 lassik

Yes, correct. Which is why I needed to write a section for [.sh] and [.bash] in that file in order to save default settings for shfmt; and using -ln only doesn't cause shfmt to read these sections because it's based on filenames, hence the tweak in -filename.

rolandmas avatar Oct 23 '23 08:10 rolandmas