From 388646eab0259c7e7410fe51679d6e4191cd8ab4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Nov 2018 01:19:18 +0100 Subject: [PATCH 1/2] Use official shellcheck image This patch switches the shellcheck image to use the official image from Docker Hub. Note that this does not yet update shellcheck to the latest version (v0.5.x); Shellcheck v0.4.7 added some new checks, which makes CI currently fail, so will be done in a follow-up PR. Instead, the v0.4.6 version is used in this PR, which is closest to the same version as was installed in the image before this change; ``` docker run --rm docker-cli-shell-validate shellcheck --version ShellCheck - shell script analysis tool version: 0.4.4 license: GNU General Public License, version 3 website: http://www.shellcheck.net ``` Signed-off-by: Sebastiaan van Stijn --- dockerfiles/Dockerfile.shellcheck | 11 ++++------- scripts/warn-outside-container | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dockerfiles/Dockerfile.shellcheck b/dockerfiles/Dockerfile.shellcheck index 4d0ddd3332..2507062ee9 100644 --- a/dockerfiles/Dockerfile.shellcheck +++ b/dockerfiles/Dockerfile.shellcheck @@ -1,10 +1,7 @@ -FROM debian:stretch-slim - -RUN apt-get update && \ - apt-get -y install make shellcheck && \ - apt-get clean - +FROM koalaman/shellcheck-alpine:v0.4.6 +RUN apk add --no-cache bash make WORKDIR /go/src/github.com/docker/cli ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 -CMD bash +ENTRYPOINT [""] +CMD ["/bin/sh"] COPY . . diff --git a/scripts/warn-outside-container b/scripts/warn-outside-container index e937caafeb..ecbecc0ea2 100755 --- a/scripts/warn-outside-container +++ b/scripts/warn-outside-container @@ -1,9 +1,9 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -eu target="${1:-}" -if [[ "$target" != "help" && -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]]; then +if [ "$target" != "help" ] && [ -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]; then ( echo echo From ff107b313a00c1ab8989f380e1ef65529b3f2e37 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 26 Feb 2019 12:49:44 +0100 Subject: [PATCH 2/2] Update to shellcheck v0.6.0 Signed-off-by: Sebastiaan van Stijn --- contrib/completion/bash/docker | 4 +++- dockerfiles/Dockerfile.shellcheck | 4 +--- scripts/gen/windows-resources | 8 ++++---- scripts/test/e2e/run | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 5d63ff6e6b..4e09dd5842 100644 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -1,10 +1,12 @@ #!/usr/bin/env bash -# shellcheck disable=SC2016,SC2119,SC2155 +# shellcheck disable=SC2016,SC2119,SC2155,SC2206,SC2207 # # Shellcheck ignore list: # - SC2016: Expressions don't expand in single quotes, use double quotes for that. # - SC2119: Use foo "$@" if function's $1 should mean script's $1. # - SC2155: Declare and assign separately to avoid masking return values. +# - SC2206: Quote to prevent word splitting, or split robustly with mapfile or read -a. +# - SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting). # # You can find more details for each warning at the following page: # https://github.com/koalaman/shellcheck/wiki/ diff --git a/dockerfiles/Dockerfile.shellcheck b/dockerfiles/Dockerfile.shellcheck index 2507062ee9..dd3cab79b2 100644 --- a/dockerfiles/Dockerfile.shellcheck +++ b/dockerfiles/Dockerfile.shellcheck @@ -1,7 +1,5 @@ -FROM koalaman/shellcheck-alpine:v0.4.6 +FROM koalaman/shellcheck-alpine:v0.6.0 RUN apk add --no-cache bash make WORKDIR /go/src/github.com/docker/cli ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 -ENTRYPOINT [""] -CMD ["/bin/sh"] COPY . . diff --git a/scripts/gen/windows-resources b/scripts/gen/windows-resources index 14b45e08e0..5fdc1b4ade 100755 --- a/scripts/gen/windows-resources +++ b/scripts/gen/windows-resources @@ -7,7 +7,7 @@ set -eu -o pipefail SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # shellcheck source=/go/src/github.com/docker/cli/scripts/build/.variables -source $SCRIPTDIR/../build/.variables +source "$SCRIPTDIR"/../build/.variables RESOURCES=$SCRIPTDIR/../winresources @@ -26,9 +26,9 @@ VERSION_QUAD=$(echo -n "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,) # Pass version and commit information into the resource compiler defs= -[ ! -z "$VERSION" ] && defs+=( "-D DOCKER_VERSION=\"$VERSION\"") -[ ! -z "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD") -[ ! -z "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"") +[ -n "$VERSION" ] && defs+=( "-D DOCKER_VERSION=\"$VERSION\"") +[ -n "$VERSION_QUAD" ] && defs+=( "-D DOCKER_VERSION_QUAD=$VERSION_QUAD") +[ -n "$GITCOMMIT" ] && defs+=( "-D DOCKER_COMMIT=\"$GITCOMMIT\"") function makeres { "$WINDRES" \ diff --git a/scripts/test/e2e/run b/scripts/test/e2e/run index bdff2ce3e3..51dc24ff17 100755 --- a/scripts/test/e2e/run +++ b/scripts/test/e2e/run @@ -70,7 +70,7 @@ function runtests { GOPATH="$GOPATH" \ PATH="$PWD/build/:/usr/bin:/usr/local/bin:/usr/local/go/bin" \ DOCKER_CLI_E2E_PLUGINS_EXTRA_DIRS="$PWD/build/plugins-linux-amd64" \ - "$(which gotestsum)" -- ./e2e/... ${TESTFLAGS-} + "$(command -v gotestsum)" -- ./e2e/... ${TESTFLAGS-} } export unique_id="${E2E_UNIQUE_ID:-cliendtoendsuite}"