diff --git a/src/shellcheck/devcontainer-feature.json b/src/shellcheck/devcontainer-feature.json index 4b5e28e..204cc50 100644 --- a/src/shellcheck/devcontainer-feature.json +++ b/src/shellcheck/devcontainer-feature.json @@ -12,6 +12,11 @@ ], "default": "os-provided", "description": "Select or enter a ShellCheck version." + }, + "installPath": { + "type": "string", + "default": "/usr/local/bin", + "description": "The path where ShellCheck will be installed." } }, "installsAfter": [ diff --git a/src/shellcheck/install.sh b/src/shellcheck/install.sh index c92459e..c05e47c 100755 --- a/src/shellcheck/install.sh +++ b/src/shellcheck/install.sh @@ -1,17 +1,17 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh set -e SHELLCHECK_VERSION="${VERSION:-"os-provided"}" INSTALL_PATH="${INSTALLPATH:-"/usr/local/bin"}" -if [[ "$(id -u)" -ne 0 ]]; then +if [ "$(id -u)" -ne 0 ]; then printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' exit 1 fi -if [[ "${SHELLCHECK_VERSION}" = "os-provided" ]]; then +if [ "${SHELLCHECK_VERSION}" = "os-provided" ]; then apt update --yes apt install --no-install-recommends --yes shellcheck @@ -27,7 +27,7 @@ if ! type curl >/dev/null 2>&1; then curl_installed="true" fi -if [[ "${SHELLCHECK_VERSION}" = "latest" ]]; then +if [ "${SHELLCHECK_VERSION}" = "latest" ]; then SHELLCHECK_VERSION="$(curl -s --head https://github.com/koalaman/shellcheck/releases/latest | sed -nr 's/location:.*\/v(.+)/\1/ip' | tr -d '\r')" fi @@ -47,6 +47,6 @@ url="https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERS curl -sSL "${url}" | tar --strip-components=1 -Jxvf - -C "${INSTALL_PATH}" "shellcheck-v${SHELLCHECK_VERSION}/shellcheck" -if [[ -n "${curl_installed}" ]]; then +if [ -n "${curl_installed}" ]; then apt purge curl --autoremove --yes fi diff --git a/test/shellcheck/scenarios.json b/test/shellcheck/scenarios.json index 212d183..e64f3c9 100644 --- a/test/shellcheck/scenarios.json +++ b/test/shellcheck/scenarios.json @@ -1,15 +1,15 @@ { "shellcheck-version": { - "image": "mcr.microsoft.com/devcontainers/base:debian", + "image": "debian:latest", "features": { "shellcheck": { - "version": "0.7.0" + "version": "0.8.0" } } }, "shellcheck-install-path": { - "image": "mcr.microsoft.com/devcontainers/base:debian", + "image": "debian:latest", "features": { "shellcheck": { "installPath": "/usr/bin" diff --git a/test/shellcheck/shellcheck-version.sh b/test/shellcheck/shellcheck-version.sh index 96a727e..59a26c3 100755 --- a/test/shellcheck/shellcheck-version.sh +++ b/test/shellcheck/shellcheck-version.sh @@ -11,7 +11,7 @@ source dev-container-features-test-lib # Feature-specific tests # The 'check' command comes from the dev-container-features-test-lib. Syntax is... # check