Re: [dev] Shell style guide

From: Anselm R Garbe <>
Date: Fri, 9 Sep 2016 07:29:18 +0200

Hi there,

On 6 September 2016 at 20:35, Evan Gates <> wrote:
> projects have traditionally been small amounts of pure C.
> The code tends towards simplicity and correctness. I value this and
> have learned much over the past years from reading and contributing to
> various projects.
> The addition of stali means there will probably be a fair amount of
> shell scripting. In my experience the vast majority of shell scripts
> are complete crap. Worse than poor style are poor practices that
> create broken code. As such I propose that we add a shell scripting
> style guide to go along with the existing C style guide in hopes of
> keeping's shell scripts as clean, simple, and correct as
> the C code.
> I think it should include the following, and probably some more. Many
> of these rules are covered in the only bash guide I've found that
> doesn't include bad practices. It also has a lot of information
> pertaining to POSIX sh. Please check out the guide[0], faq[1], and
> common pitfalls[2].

I appreciate your efforts of coming up with some sh styleguide. A side
note to that, I prefer calling test explicitely, instead of using the
weirdo [ ] symlinks in while/if statements.

Nevertheless, after an excursion to sh for several years, I'm kind of
favouring 9base/rc again, after all. For stali I now tend to adopt rc
as primary scripting language for the target system as well. For the
build host environment I would rather stick to sh+make instead of
rc+mk. We have to live with the fact that a build host environment is
poisoned with crap bloat to hell anyways. But for ideal target system,
we should stick to technologies that have been designed with clarity
and cleanliness in mind. rc is the perfect example for a decent shell

When I started 9base and Uriel started werc and other rc-based stuff,
we concluded that one cannot really write portable scripts with sh.
You have to rely on a defined userland. The Plan 9 derived userland
offers this definition. I agree that sbase goes into a similar
direction, but the danger remains when using sh, that some stuff will
end up in pretty mixed environments.

For serious stuff like werc, rc was the right choice, because it
relies on this definite userland environment and hence does not allow
for ambiguity.

I just wanted to mention this, as this is one of my very recent
decisions about stali's future.

Received on Fri Sep 09 2016 - 07:29:18 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 09 2016 - 07:36:13 CEST