mylinuxforwork / dotfiles

The ML4W Dotfiles for Hyprland - An advanced and full-featured configuration for the dynamic tiling window manager Hyprland including an easy to use installation script for Arch based Linux distributions.
GNU General Public License v3.0
868 stars 68 forks source link

Automatic formatting to allow for easier maintaince of forks #289

Open ZeroEcks opened 3 weeks ago

ZeroEcks commented 3 weeks ago

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.

mylinuxforwork commented 2 weeks ago

@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?

ZeroEcks commented 2 weeks ago

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.

mylinuxforwork commented 2 weeks ago

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

mylinuxforwork commented 2 weeks ago

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