can-lint.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # lint — complains about misformatted files and other problems.
  12. set -euo pipefail
  13. cd "$(dirname "$0")/../../../.."
  14. . misc/shlib/shlib.bash
  15. if [[ ! "${MZDEV_NO_SHELLCHECK:-}" ]]; then
  16. if ! command_exists shellcheck; then
  17. echo -e "lint: $(red fatal:) unable to find \`shellcheck\` command on your system" >&2
  18. echo -e "hint: https://github.com/koalaman/shellcheck#installing" >&2
  19. echo -e "hint: you can disable shellcheck locally by setting \$MZDEV_NO_SHELLCHECK=1" >&2
  20. exit 1
  21. fi
  22. version=$(shellcheck --version | grep version: | grep -oE "[0-9]+\.[0-9]+\.[0-9]+" || echo "0.0.0+unknown")
  23. if ! version_compat "0.7.0" "$version"; then
  24. echo -e "lint: $(red fatal:) shellcheck v0.7.0+ is required" >&2
  25. echo -e "hint: detected version \"$version\"" >&2
  26. echo -e "hint: you can disable shellcheck locally by setting \$MZDEV_NO_SHELLCHECK=1" >&2
  27. exit 1
  28. fi
  29. fi