Least changes needed to let Shellcheck parse to end #202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Shellcheck is a tool for static analysis of various kinds of shell scripts. It has really helped me in the past. I would like it to run from beginning to end on ssdtPRGen.sh.
tl;dr:
Shellcheck gets stuck on some lines it considers syntax errors: parenthesized let expressions without quotes. This patch adds the quotes. You don't need to take the patch; you could use this branch in my repository to run Shellcheck.
Background
In ksh (I know we're in bash!) the following is a syntax error:
whereas this is ok:
Shellcheck will barf and die on the first, even when it is checking Bash scripts. Shellcheck may be right or wrong, but in order to get all its other functionality, a few let expressions in
ssdtPRGen.sh
need to be tweaked. I decided the least-possible-change was double-quoting the expressions. Here are the other possibilities:The parentheses don't do anything, so another way of rewriting is:
Bash numeric evaluation will dereference variables for you, so this does the same thing:
bash
let a="b * c"