On Sat, Feb 13, 2010 at 9:32 AM, Pierre Schmitz <pierre@archlinux.de> wrote:
Hi all,
while looking at our devtools, other scripts we have written together and even PKGBUILDs, you will see as much different types of indention, bracing etc. as there are authors.
This always annoyed me and as I just watched Greg's talk at fosdem about committing kernel patches I'll go ahead and will start with devtools.
I would suggest to use this coding style:
* indent with tabs * tabs have 8 characters * don't use more than 132 columns * opening braces are top right, closing are bottom left:
Ew. I prefer to write bash like python. 4 space indentation. If you want to enforce using tabs, PLEASE add modelines to the files, as my editor defaults to 4 space indentation. I agree with the braces. The width thing... yeah that's fine. 80 chars should be enough for bash, though. However, wide terminals have existed since the 70s so I see no issue with using 132 chars.
* if and for statements are like this:
Fine. I assume you're trying to point out that they SHOULDN'T be done like: if true then echo "Yay" fi Correct?
* use single quotes if a string does not parseable content
That seems a little nitpick-y to me. What's the point of calling foul if I write: echo "Hello, Pierre"
We could also talk about using `` or $(); source vs. .; $foo vs. ${bar} etc.. But that's probably too much.
Agreed. However, if we want to go with "minimum support" and get down to the ash/dash level, then it's important.