AsahiLinux / asahi-installer

Asahi Linux installer
MIT License
782 stars 104 forks source link

toil: update all shell scripts to pass static analysis with shfmt #309

Closed PaulCharlton closed 3 days ago

PaulCharlton commented 3 days ago

toil: update all shell scripts to pass static analysis with shfmt

I imagine there may be several round trips on this issue to get an agreed style guide.

at the moment, the formatting required is configured as follows:

shellcheck --shell=bash 

and

shfmt -d -i 2 -ci -sr -kp -s -sr .

whilst shellcheck has a lot of knobs to twiddle for various styles and usage, the default enforces POSIX bash definition fairly well.

however, shfmt has very few knobs, mostly via command line arguments, and the default above represents: 1) output diff between existing and desired format 2) 2 spaces per indent instead of tabs 3) indents inside of case statement 4) space around redirects which pretty much just adds spaces after redirect stream operators 5) "simplify" which eliminates redundant operators such as: 1) "$" prefix on variable names inside of "((...))"

related: #307

PaulCharlton commented 3 days ago

shfmt can be used locally to coerce a file to cooperate by overwriting it with the desired format as follows:

shfmt -d -i 2 -ci -sr -kp -s -sr -w foo.sh
marcan commented 3 days ago

Nobody asked for this and now I'm annoyed that you're spamming our bug tracker with duplicate issues (presumably with some kind of script).