News for hackers. Stuff that matters.
Re:Shell Style Guide by moviuro on Tuesday May 15, 2018 @10:36AM (#17074195)
It is, but don't forget it's a guide for Google engineers on the Google machines.

People who share code for the world to use should use:

- `#!/usr/bin/env bash`

- or `#!/bin/sh` for POSIX shell scripting

Re:Shell Style Guide by peterwwillis on Tuesday May 15, 2018 @10:55AM (#17074366)
/bin/sh is most often either the C shell, Dash, or Ash, not the Bourne shell. Bourne shell extensions will cause the script to fail.

edit: bourne again shell

Re:Shell Style Guide by moviuro on Tuesday May 15, 2018 @11:15AM (#17074547)
You certainly meant /bin/sh is not the Bourne again shell. I updated my comment to clear any possible misunderstanding

https://en.wikipedia.org/wiki/Bourne_shell

https://en.wikipedia.org/wiki/Bourne-again_shell

Re:Shell Style Guide by floatboth on Tuesday May 15, 2018 @11:17AM (#17074558)
/bin/sh shouldn't be a C shell, it's always a POSIX-compatible shell IIRC
Re:Shell Style Guide by scruple on Tuesday May 15, 2018 @12:43PM (#17075289)
In the wild, hopefully not, but I do remember coming across /bin/sh executing csh in an obscure RTOS-ish / proprietary flavor of Linux that we were prototyping at a previous employer. Would've been around 2008. I can't remember the variant, but I remember being caught off-guard by it.
Re:Shell Style Guide by gkya on Tuesday May 15, 2018 @10:57PM (#17079696)
AFAIK /bin/sh is standard; if you cannot trust that /bin/sh is a Bourne-like sh, you might as well have to assume /usr/bin/env can not be what it was meant to be too.
Re:Shell Style Guide by peterwwillis on Tuesday May 15, 2018 @12:14PM (#17075058)
I suppose you're right, though the main point is it may not have Bourne-again extensions
Re:Shell Style Guide by cowmoo728 on Tuesday May 15, 2018 @11:47AM (#17074849)
I once triggered an automatic deploy that ran a bash script that minified a bunch of css/html/js assets and pushed them to S3, at some path like `/assets/vX.X.X/whatever.css`. Unfortunately, a few of our deploy boxes had Dash instead of Bourne shell, and when it ran on dash it failed to parse the version tag to push and ended up pushing an empty dir to /assets - deleting everything. Fun experience.
Re:Shell Style Guide by michaelcampbell on Wednesday May 16, 2018 @02:26PM (#17085070)
> /bin/sh is most often either the C shell,

Never once have I ever seen this. In 25+ years.

Re:Shell Style Guide by h1d on Tuesday May 15, 2018 @06:11PM (#17078354)
Doesn't explain why Google wouldn't use env unless there's a good reason to avoid env.
Re:Shell Style Guide by moviuro on Wednesday May 16, 2018 @03:17AM (#17080574)
Top of my head:

- it works

- it's simple

- they know that bash is in /bin

- maybe it avoids a needless call to env, resulting in better startup time (see e.g. https://news.ycombinator.com/item?id=16978932 for a similar situation with python)