diff options
author | Matthias Beyer <matthias.beyer@ifm.com> | 2022-08-06 08:55:40 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@ifm.com> | 2022-08-16 16:06:11 +0200 |
commit | 785b125b0488195e0cb722ccc96b9fcb5007117b (patch) | |
tree | 96fed6e7c6c36b29393a77532dc9fe6afb167196 | |
parent | 20cfce1f660b2ead3f7b8ea633fcb156b5b0e598 (diff) |
Fix: Add missing quotes
This fixes shellcheck SC2086
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
-rw-r--r-- | plugins/tedge_docker_plugin/tedge_docker_plugin.sh | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/plugins/tedge_docker_plugin/tedge_docker_plugin.sh b/plugins/tedge_docker_plugin/tedge_docker_plugin.sh index 8d47c92e..37006450 100644 --- a/plugins/tedge_docker_plugin/tedge_docker_plugin.sh +++ b/plugins/tedge_docker_plugin/tedge_docker_plugin.sh @@ -15,7 +15,7 @@ EOF } unsupported_args_check() { - if [ -n $1 ]; then + if [ -n "$1" ]; then echo "Unsupported arguments: $*" exit 1 fi @@ -30,7 +30,7 @@ extract_image_tag_from_args() { shift # Pop image name from args list IMAGE_TAG=$IMAGE_NAME - if [ -n $1 ]; then + if [ -n "$1" ]; then case "$1" in --module-version) IMAGE_VERSION="$2" @@ -48,7 +48,7 @@ extract_image_tag_from_args() { } -if [ -z $1 ]; then +if [ -z "$1" ]; then echo "Provide at least one subcommand\n" usage exit 1 @@ -71,11 +71,11 @@ case "$COMMAND" in extract_image_tag_from_args "$@" # Stop all containers using the provided image name - containers=$(docker ps -a --format "{{.ID}} {{.Image}}" | grep $IMAGE_NAME | awk '{print $1}') || exit 2 + containers=$(docker ps -a --format "{{.ID}} {{.Image}}" | grep "$IMAGE_NAME" | awk '{print $1}') || exit 2 if [ -z "$containers" ] then echo "No containers to update. Spawning a new one." - docker run -d $IMAGE_TAG || exit 2 + docker run -d "$IMAGE_TAG" || exit 2 else echo "Updating existing containers." for container in $containers @@ -83,14 +83,14 @@ case "$COMMAND" in docker rm $(docker stop "$container") || exit 2 # Spawn new containers with the provided image name and version to replace the stopped one - docker run -d $IMAGE_TAG || exit 2 + docker run -d "$IMAGE_TAG" || exit 2 done fi ;; remove) - extract_image_tag_from_args $@ + extract_image_tag_from_args "$@" - containers=$(docker ps -a --format "{{.ID}} {{.Image}}" | grep $IMAGE_TAG | awk '{print $1}') || exit 2 + containers=$(docker ps -a --format "{{.ID}} {{.Image}}" | grep "$IMAGE_TAG" | awk '{print $1}') || exit 2 if [ -z "$containers" ] then echo "No containers found for the image: $IMAGE_TAG" @@ -101,7 +101,7 @@ case "$COMMAND" in done ;; finalize) - unsupported_args_check $@ + unsupported_args_check "$@" # Prune all the unused images. The --force command is used to avoid a [y/N] user prompt docker image prune --all --force || exit 2 ;; |