Skip to content

Commit

Permalink
CodingGuidelines: spell Arithmetic Expansion with $(($var))
Browse files Browse the repository at this point in the history
POSIX wants shells to support both "N" and "$N" and requires them to yield
the same answer to $((N)) and $(($N)), but we should aim for portability
in a case like this, especially when the price we pay to do so is so
small, i.e. a few extra dollars.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Sep 27, 2010
1 parent 4098f67 commit 055467d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ For shell scripts specifically (not exhaustive):

- We use Arithmetic Expansion $(( ... )).

- Inside Arithmetic Expansion, spell shell variables with $ in front
of them, as some shells do not grok $((x)) while accepting $(($x))
just fine (e.g. dash older than 0.5.4).

- No "Substring Expansion" ${parameter:offset:length}.

- No shell arrays.
Expand Down

0 comments on commit 055467d

Please sign in to comment.