News for hackers. Stuff that matters.
Re:Shell Style Guide from Google by ymse on Saturday June 04, 2016 @06:03PM (#11838330)
> Executables must start with #!/bin/bash

I've started using #!/usr/bin/env bash for compatibility with non-FHS distros such as NixOS.

Happy to see arrays omitted; if you find yourself in need of bash arrays you should definitely consider a proper language.

I tend to stick to POSIX shell to the extent possible, but readonly variables and [[ ]] syntactic sugar makes sense when maintainability is more important than portability.

Re:Shell Style Guide from Google by jxy on Saturday June 04, 2016 @11:16PM (#11839461)
Those are exactly two things I don't agree.

> Executables must start with #!/bin/bash

Either they never use *BSD, or they put their bash there. Unbelievable choice.

> If you find you need to use arrays for anything more than assignment of ${PIPESTATUS}, you should use

I use array all the time and never used PIPESTATUS. So what?

Re:Shell Style Guide from Google by ymse on Saturday June 04, 2016 @11:28PM (#11839494)
Frankly, I find hard-coding #!/bin/bash sensible in a large corporate setting such as Google. It prevents PATH manipulation and they obviously have a uniform and controlled environment.

Bash arrays can be convenient, but at that level of complexity Python or Ruby are much easier to read and understand (and necessarily maintain).

Re:Shell Style Guide from Google by asuffield on Sunday June 05, 2016 @08:14AM (#11840546)
(Tedious disclaimer: my opinion only, not speaking for anybody else. I'm an SRE at Google.)

We run everything on prodimage, so operating system compatibility isn't really an issue.

Realistically, any time somebody sends me a code review with a shell script in it, my first comment is going to be "Why is this a shell script? Rewrite it in a supported language."

Re:Shell Style Guide from Google by riskrisk on Sunday June 05, 2016 @02:49AM (#11839938)
> .. they never use *BSD ..

pretty much

Re:Shell Style Guide from Google by mcsaucy on Sunday June 05, 2016 @02:59PM (#11842472)
Re: arrays -- I generally agree, but they are best solution to certain otherwise simple problems, like storing command arguments. `cmd $FLAGS` is objectively more dangerous than `cmd "${FLAGS[@]}"` due to the globbing and word-splitting issues the former exposes. In my experience, devs are more likely to opt for the former when the latter is forbidden than switch languages (because that's work).