awslabs / aws-container-images-toolkit

A collection of tools to statically and dynamically identify public container images that are hosted on Docker Hub.
https://aws.amazon.com/blogs/containers/advice-for-customers-dealing-with-docker-hub-rate-limits-and-a-coming-soon-announcement/
Apache License 2.0
69 stars 13 forks source link

making modifications based on shellcheck -S error #5

Closed elreydetoda closed 3 years ago

elreydetoda commented 3 years ago

NOTE: I didn't test these changes on my machine because I didn't have something to run them against. So, before merging you might want to check and make sure everything still work. ( in theory it should )

Description of changes: I modified the following scripts:

so that they no longer used the [@] inside of if conditions, because based on a really cool tool called shellcheck it might cause errors: https://github.com/koalaman/shellcheck/wiki/SC2199

This was the command that I ran, with it's output:

$ shellcheck -S error */*.sh                       

In codebuild/detect-images.sh line 42:
    if [[ ! -z "${dhimages[@]+"${dhimages[@]}"}" ]]; then
               ^-- SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

In ecs/detect-images.sh line 70:
    if [[ ! -z "${dhimages[@]+"${dhimages[@]}"}" ]]; then
               ^-- SC2199: Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

I only did the error severity of shellcheck for this PR, so that it was focused and it could be a way to start the conversation about using it in the repo.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.