while [[ "$#" -gt 0 ]]; do
Spot checking code for basic bash mistakes like this tends to tell me the quality of the code overall, as these are basic mistakes. $0.02https://www.gnu.org/software/bash/manual/html_node/Double-Qu...
X="08"
if [[ "$X" -eq 8 ]]; then
echo Y
fi
Use `bash -x` to run it in debug mode: $ bash -x test.sh
+ X=08
+ [[ 08 -eq 8 ]]
test.sh: line 2: [[: 08: value too great for base (error token is "08")
This comes into play if you're dealing with things like IPv4 address, where it is technically allowable to have leading zeros, however by convention it's never done because of code traps which see those leading zeros as octal mode, not decimal.Plus, left and single operands, in bash conditions, don't require quoting, so a lean style is actually not to use them at all.
That's false:
x='foo bar'; [ $x = 'foo bar' ]; echo $?
-bash: [: too many arguments
x='foo bar'; [ "$x" = 'foo bar' ]; echo $?
0I do a non-trivial amount of shell scripting, and there is only one warning I disable in shellcheck on a general basis (SC2016).
The author of this script clearly doesn't like quoting where the underlying value is guaranteed not to include special characters (or space), although this is somewhat inconsistent with the fact that he's using quotes in several patterns where it's not needed (eg. left or single operands in bash conditionals, or in variables initialization).
On can consider always quoting a defensive practice. In a fragile language like Bash, I personally think defensive practices are very important, so the first impression I get from a Bash program not adopting them is "not great".