summaryrefslogtreecommitdiff
path: root/doc/bash-style.cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-01-22 13:57:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-01-22 13:57:16 +0200
commit4585375ae8c891242640fc9628e1475c78925fdf (patch)
tree3705b0072a118564f92723a9d7b6edc36c65932e /doc/bash-style.cli
parent91b984339508d8163378d376b7ee417088c48bce (diff)
Add note to Bash guide on arithmetic expansion ( $(( )) )
Diffstat (limited to 'doc/bash-style.cli')
-rw-r--r--doc/bash-style.cli13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/bash-style.cli b/doc/bash-style.cli
index f81479b..9e90e8a 100644
--- a/doc/bash-style.cli
+++ b/doc/bash-style.cli
@@ -224,6 +224,19 @@ along these lines:
rm -f \"$dir/$name\".*
\
+\N|One exception to this quoting rule is arithmetic expansion (\c{$((\ ))}):
+Bash treats it as if it was double-quoted and, as a result, any inner quoting
+is treated literally. For example:
+
+\
+z=$(($x + $y)) # Ok.
+z=$((\"$x\" + \"$y\")) # Error.
+z=$(($x + $(echo \"$y\"))) # Ok.
+\
+
+|
+
+
If you have multiple values (e.g., program arguments) that may contain spaces,
don't try to handle them with quoting and use arrays instead. Here is a
typical example of a space-aware argument handling: