According to the bash manual, there is no syntactical difference. The bash-parser on the other hand seems to have a different opinion on that when dealing with arithmetic expressions:
$ echo "$BASH_VERSION"
5.2.15(1)-release
$ echo $((""))
0
$ echo $((''))
bash: '': syntax error: operand expected (error token is "''")
Related:
There seems to be a subtle difference introduced in Bash 5.2. The manual states:
(( expression ))The arithmetic expression is evaluated according to the rules described below (see Shell Arithmetic). The expression undergoes the same expansions as if it were within double quotes, but double quote characters in
expressionare not treated specially and are removed. If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1.Source: Bash Reference Manual: Section Conditional Constructs
This implies that (("")) is equivalent to (()) but (('')) is a syntactical error as single quotes are not removed from expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With