├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── LICENSE ├── README.md └── bin ├── install └── list-all /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: 'github-actions' 4 | directory: '/' 5 | schedule: 6 | interval: 'daily' 7 | ignore: 8 | - dependency-name: 'asdf-vm/actions' # v4 treats asdf-vm v0.16.0+ as the primary version 9 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | paths-ignore: 8 | - '**.md' 9 | pull_request: 10 | paths-ignore: 11 | - '**.md' 12 | 13 | jobs: 14 | plugin_test: 15 | timeout-minutes: 10 16 | strategy: 17 | fail-fast: false 18 | matrix: 19 | os: 20 | - ubuntu-latest 21 | - macos-14 # aarch64 22 | - macos-13 # x86_64 23 | runs-on: ${{ matrix.os }} 24 | steps: 25 | - uses: asdf-vm/actions/plugin-test@v3 26 | with: 27 | command: 'shellcheck --version' 28 | asdf_branch: 'v0.15.0' # v0.16.0 introduced breaking changes 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jack Henry & Associates 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # asdf-shellcheck 2 | 3 | ![Build Status](https://github.com/luizm/asdf-shellcheck/actions/workflows/build.yml/badge.svg) 4 | 5 | 6 | [shellcheck](https://github.com/koalaman/shellcheck) plugin for the [asdf](https://github.com/asdf-vm/asdf) version manager. 7 | 8 | For more informations about the [asdf usage](https://asdf-vm.com/#/core-commands). 9 | 10 | ## Add plugin 11 | 12 | ``` 13 | asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git 14 | ``` 15 | 16 | ## Install 17 | 18 | ``` 19 | asdf install shellcheck 0.7.0 20 | ``` 21 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | test -n "$ASDF_INSTALL_VERSION" || { 6 | echo 'Missing ASDF_INSTALL_VERSION' 7 | exit 1 8 | } 9 | 10 | test -n "$ASDF_INSTALL_PATH" || { 11 | echo 'Missing ASDF_INSTALL_PATH' 12 | exit 1 13 | } 14 | 15 | _get_arch() { 16 | local arch; arch=$(uname -m) 17 | case $arch in 18 | armv*) arch="armv6hf";; 19 | aarch64 | arm64) arch="aarch64";; 20 | x86_64) arch="x86_64";; 21 | esac 22 | echo "$arch" 23 | } 24 | 25 | _get_platform() { 26 | uname | tr '[:upper:]' '[:lower:]' 27 | } 28 | 29 | _get_download_url() { 30 | local -r version="$1" 31 | local -r platform="$2" 32 | local -r arch="$3" 33 | 34 | echo "https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.${platform}.${arch}.tar.xz" 35 | } 36 | 37 | install() { 38 | local -r version=$1 39 | local -r install_path=$2 40 | 41 | local -r bin_install_path="${install_path}/bin" 42 | local -r bin_path="${bin_install_path}/shellcheck" 43 | 44 | local -r platform="$(_get_platform)" 45 | local arch; arch="$(_get_arch)" 46 | # Shellcheck supports Darwin/ARM only starting from v0.10.0. 47 | # If the requested version is lower than v0.10.0, then fall back to the x86_64 version. 48 | local -r version_parts=(${version//./ }) 49 | if [ "${version_parts[0]}" -eq 0 ] && [ "${version_parts[1]}" -lt 10 ]; then 50 | test "$platform" == "darwin" && arch="x86_64" 51 | fi 52 | 53 | local -r download_url="$(_get_download_url "${version}" "${platform}" "${arch}")" 54 | 55 | mkdir -p "${bin_install_path}" 56 | 57 | echo "Downloading shellcheck from ${download_url} to ${bin_install_path}" 58 | # curl to tar, without files on disk 59 | curl -Ls "${download_url}" | tar -xJv --strip-components=1 -C "${bin_install_path}" "shellcheck-v${version}/shellcheck" 60 | chmod +x "${bin_path}" 61 | } 62 | 63 | install "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH" 64 | -------------------------------------------------------------------------------- /bin/list-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | releases_url="https://api.github.com/repos/koalaman/shellcheck/releases" 4 | 5 | if [ -n "$GITHUB_API_TOKEN" ]; then 6 | cmd="curl -s -H 'Authorization: token $GITHUB_API_TOKEN' $releases_url" 7 | else 8 | cmd="curl -s $releases_url" 9 | fi 10 | 11 | sort_versions() { 12 | sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | 13 | LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' 14 | } 15 | 16 | eval "$cmd" | 17 | grep -oE "tag_name\": *\".{1,15}\"," | 18 | sed 's/tag_name\": *\"v//;s/\",//' | 19 | sort_versions | grep -Ev "latest|stable" | tr "\n" " " 20 | --------------------------------------------------------------------------------