Skip to content

Commit

Permalink
Use arithmetic bash comparisons (#1776)
Browse files Browse the repository at this point in the history
As discussed in
tiny-pilot/style-guides#19 (comment),
and in eager compliance with the [Google bash style
guide](https://google.github.io/styleguide/shellguide.html#s6.9-arithmetic),
we can replace all instances of `[[ -gt ]]` or `[[ -lt ]]` with
arithmetic expressions (`(( > ))` or `(( < ))`).

I’ve briefly tested all scripts, so from my side a double-check on the
code would be enough as review.
<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1776"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>

Co-authored-by: Jan Heuermann <[email protected]>
  • Loading branch information
jotaen4tinypilot and jotaen authored Apr 5, 2024
1 parent aa9bd31 commit 942845f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bundler/verify-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [[ "${BUNDLE_SIZE_BYTES}" -eq 0 ]]; then
>&2 echo 'Bundle size is zero.'
exit 1
fi
if [[ "${BUNDLE_SIZE_BYTES}" -gt 10000000 ]]; then
if (( "${BUNDLE_SIZE_BYTES}" > 10000000 )); then
>&2 echo 'Bundle size is larger than 10mb.'
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EOF
}

# Parse command-line arguments.
while [[ "$#" -gt 0 ]]; do
while (( "$#" > 0 )); do
case "$1" in
--help)
print_help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ EOF

# Parse command-line arguments.
TARGET_FILE=''
while [[ "$#" -gt 0 ]]; do
while (( "$#" > 0 )); do
case "$1" in
--help)
print_help
Expand Down
4 changes: 2 additions & 2 deletions dev-scripts/run-e2e-tests
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ EOF
# Parse command-line arguments.
E2E_BASE_URL=''
PLAYWRIGHT_ARGS=()
while [[ "$#" -gt 0 ]]; do
while (( "$#" > 0 )); do
case "$1" in
--help)
print_help
exit
;;
--base-url)
if [[ "$#" -lt 2 ]]; then
if (( "$#" < 2 )); then
shift;
break;
fi
Expand Down

0 comments on commit 942845f

Please sign in to comment.