servo/docs/STYLE_GUIDE.md
author Mike Hommey <mh+mozilla@glandium.org>
Thu, 20 Jul 2017 11:31:14 +0900
changeset 371012 ed4688fd119a5c6714e78e67466eefe16b8e0ce1
parent 338748 fe7e4ea3cda6c5a0dc746f55e209a0b60aeffc0d
child 410283 befe8c748a4b4dad323ac9333a50c7fa0e870cfa
permissions -rw-r--r--
Bug 1382502 - Enable sccache on PGO builds. r=ted Note this will only enable it on try, autoland and mozilla-inbound, which are the only branches where sccache are enabled at the moment. Enabling on more builds (or not) is the subject of bug 1373460. Also note that bug 1181040, that ensured PGO builds weren't using sccache mentions that back then, link times went up when using sccache (with -Z7) vs. without, but that was presumably with MSVC 2013. Try suggests link times are the same using sccache now (still using -Z7, pending bug 1318370).

# Style Guide

The majority of our style recommendations are automatically enforced via our
automated linters. This document has guidelines that are less easy to lint for.

## Shell scripts

Shell scripts are OK for small tasks or wrappers, but prefer to use Python for
anything with a hint of complexity or in general.

Shell scripts should be written against bash, starting with this shebang:
```
#!/usr/bin/env bash
```

Note that the version of bash available on OS X by default is quite old, so be
careful when using new features.

Scripts should enable a few options at the top for robustness:
```
set -o errexit
set -o nounset
set -o pipefail
```

Quote all variables, using the full form: `"${SOME_VARIABLE}"`.

Use `"$(some-command)"` instead of backticks for command substitution. Note
that these should be quoted as well.