dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Automatic formatting to allow for easier maintaince of forks

Open ZeroEcks opened this issue 1 year ago • 4 comments

The Problem There are numerous oddities with the formatting such as hanging spaces at the end of lines (as seen in share/packages/general.sh for example), uneven #----- comments, weird spacing around if [...] ;then vs if [...]; then, etc. These will make it hard for me to maintain a consistent fork as I would be making trivial changes to files, and would require me to further separate from upstream, where I would prefer not to.

The Solution

I think it would be best if this project adopted a specific bash formatter and style, so that it's easier to maintain a consistent style on my fork.

I might even have time to run a formatter over the code and provide a script that could be used in git hooks / ci / whatever if you want? I am mostly opening this issue as a vibe check as to if that is even wanted as a PR?

Alternatives I can just maintain a fork anyway, it's really not that big of a deal really, I was mostly wanting to vibe check if this would be a welcome contribution?

There is also the possibility there is a style that is being followed, and if it could be clarified, that would help with configuring my editor.

ZeroEcks avatar Oct 03 '24 12:10 ZeroEcks

@ZeroEcks This is a very interesting comment. You're talking about bash formatter. Are there add ons available or would you suggest to create a dedicated script to run over the files and highlight consistence issues?

mylinuxforwork avatar Oct 04 '24 10:10 mylinuxforwork

I'd probably recommend just running shfmt over it and maybe shellcheck (if you want) to pick up on some style / safety issues with the code. These both have autofixing capabilities, so submitting a PR + writing a helper script to run them as a hook / CI wouldn't be much effort for me. It mostly depends if that's something you want :)

I can recommend shellcheck at least though, it encourages a style of writing bash that avoids bugs.

ZeroEcks avatar Oct 04 '24 11:10 ZeroEcks

https://github.com/mylinuxforwork/dotfiles/pull/293

mylinuxforwork avatar Oct 05 '24 08:10 mylinuxforwork

https://blog.svedr.in/posts/bash-script-coding-rules/

mylinuxforwork avatar Oct 10 '24 11:10 mylinuxforwork