Skip to content

Commit 055467d

Browse files
committed
CodingGuidelines: spell Arithmetic Expansion with $(($var))
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 <[email protected]>
1 parent 4098f67 commit 055467d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Documentation/CodingGuidelines

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ For shell scripts specifically (not exhaustive):
4343

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

46+
- Inside Arithmetic Expansion, spell shell variables with $ in front
47+
of them, as some shells do not grok $((x)) while accepting $(($x))
48+
just fine (e.g. dash older than 0.5.4).
49+
4650
- No "Substring Expansion" ${parameter:offset:length}.
4751

4852
- No shell arrays.

0 commit comments

Comments
 (0)