gvmap.sh: syntax error at arithmetic compound command
Steps to reproduce
Adding '$' to '((...))' causes the contents to be executed as a command. (credit: shellcheck) Cheers
In /usr/bin/gvmap.sh line 89: while $(( $# > 0 )) ^-----------^ SC2084 (error): Remove '
' or use '_=
((expr))' to avoid executing output.For more information: https://www.shellcheck.net/wiki/SC2084 -- Remove '
' or use '_=
((expr))' t...
$ man bash
((expression)) The expression is evaluated according to the rules described below under ARITHMETIC EVALUATION. If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1. The expression undergoes the same expansions as if it were within double quotes, but double quote characters in expression are not treated specially and are removed.
...
Arithmetic Expansion Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result. The format for arithmetic expansion is:
$((expression)) The expression undergoes the same expansions as if it were within double quotes, but double quote characters in expression are not treated specially and are removed. All tokens in the expression undergo parameter and variable expansion, ** command substitution ** , and quote removal. The result is treated as the arithmetic ex‐ pression to be evaluated. Arithmetic expansions may be nested. The evaluation is performed according to the rules listed below under ARITHMETIC EVALUATION. If expression is invalid, bash prints a message indicating failure and no substitution occurs.
OS Version
$ uname -a
Linux localhost-live 6.2.9-300.fc38.x86_64 #1 (closed) SMP PREEMPT_DYNAMIC Thu Mar 30 22:32:58 UTC 2023 x86_64 GNU/Linux
Graphviz Version
$ dot -V
dot - graphviz version 7.1.0 (0)
Additional info
$ echo $#
0
$ set -- a b c
$ echo $#
3
$ if (( $# > 0 )); then echo y; else echo n; fi
y
$ if $(( $# > 0 )); then echo y; else echo n; fi
bash: 1: command not found
n