5 ms·
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 bas
by moviuro 8y ago
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
- peterwwillis 8y ago/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
- moviuro 8y agoYou 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_shell https://en.wikipedia.org/wiki/Bourne-again_shell https://en.wikipedia.org/wiki/Bourne-again_shell
- floatboth 8y ago/bin/sh shouldn't be a C shell, it's always a POSIX-compatible shell IIRC
- peterwwillis 8y agoI suppose you're right, though the main point is it may not have Bourne-again extensions
- scruple 8y agoIn 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.
- gkya 8y agoAFAIK /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.
- deleted 8y ago[deleted]
- cowmoo728 8y agoI 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.
- michaelcampbell 8y ago> /bin/sh is most often either the C shell, Never once have I ever seen this. In 25+ years.
- h1d 8y agoDoesn't explain why Google wouldn't use env unless there's a good reason to avoid env.
- moviuro 8y agoTop 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 https://news.ycombinator.com/item?id=16978932 for a similar situation with python)