Code conventions

From Nasqueron Agora
Revision as of 00:13, 9 November 2015 by Dereckson (talk | contribs) (Created page with "== Shell scripts == UNIX agnosticism: * Don't assume absolue path, use `#!/usr/bin/env bash` and not `#!/bin/bash` (it could be elsewhere on BSD or Solaris) * Use `sh` as mus...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Shell scripts

UNIX agnosticism:

  • Don't assume absolue path, use `#!/usr/bin/env bash` and not `#!/bin/bash` (it could be elsewhere on BSD or Solaris)
  • Use `sh` as must as possible, try to avoid `bash`, document exceptions rationale in your commits

Whitespaces:

  • One whitespace line between shebang and actual content
  • Indent with tabulations

File names:

  • We use hyphens (-) as separators, not underscores or camelcase.
  • Filename should start by a verb if it performs an action
  • Don't use .sh extensions (sometimes you'll see them on Phabricator pastes' titles, but it has been added there, so Phab knows shell syntax highlighting should be used)