diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23f2f544c..44a10ecd9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,6 +35,13 @@ repos: types_or: [python, pyi] require_serial: true stages: [pre-commit, manual] + # Shellcheck + - id: shellcheck + name: Check shell scripts + entry: pixi run --environment=lint shellcheck + language: system + types: [shell] + stages: [pre-commit, manual] # GitHub Actions - id: actionlint name: Lint GitHub Actions workflow files diff --git a/examples/pypi/activate.sh b/examples/pypi/activate.sh index 34fcbf7ae..31bee389b 100644 --- a/examples/pypi/activate.sh +++ b/examples/pypi/activate.sh @@ -1 +1,3 @@ +#!/usr/bin/env bash + export MY_SUPER_ENV=hello diff --git a/install/install.sh b/install/install.sh index de6078596..77317296d 100644 --- a/install/install.sh +++ b/install/install.sh @@ -39,7 +39,7 @@ else DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BINARY}.${EXTENSION}" fi -printf "This script will automatically download and install Pixi (${VERSION}) for you.\nGetting it from this url: $DOWNLOAD_URL\n" +printf "This script will automatically download and install Pixi (%s) for you.\nGetting it from this url: %s\n" "$VERSION" "$DOWNLOAD_URL" if ! hash curl 2> /dev/null && ! hash wget 2> /dev/null; then echo "error: you need either 'curl' or 'wget' installed for this script." @@ -125,7 +125,7 @@ update_shell() { LINE="$2" # shell update can be suppressed by `PIXI_NO_PATH_UPDATE` env var - [[ ! -z "${PIXI_NO_PATH_UPDATE:-}" ]] && echo "No path update because PIXI_NO_PATH_UPDATE has a value" && return + [[ -n "${PIXI_NO_PATH_UPDATE:-}" ]] && echo "No path update because PIXI_NO_PATH_UPDATE has a value" && return # Create the file if it doesn't exist if [ -f "$FILE" ]; then diff --git a/src/shell_snippets/pixi-bash.sh b/src/shell_snippets/pixi-bash.sh index 45d8c8693..2a90205e2 100644 --- a/src/shell_snippets/pixi-bash.sh +++ b/src/shell_snippets/pixi-bash.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash pixi() { local first_arg="$1" local cmd="$PIXI_EXE $*" diff --git a/src/shell_snippets/pixi-zsh.sh b/src/shell_snippets/pixi-zsh.sh index 5d0a0e4bb..43d8f3a30 100644 --- a/src/shell_snippets/pixi-zsh.sh +++ b/src/shell_snippets/pixi-zsh.sh @@ -1,3 +1,4 @@ +# shellcheck disable=all pixi() { local first_arg="$1" local cmd="$PIXI_EXE $*" diff --git a/tests/data/channels/recipes/trampoline/print_path.sh b/tests/data/channels/recipes/trampoline/print_path.sh index 866aea1c6..e49665fb4 100644 --- a/tests/data/channels/recipes/trampoline/print_path.sh +++ b/tests/data/channels/recipes/trampoline/print_path.sh @@ -1,3 +1,3 @@ #!/bin/bash -echo $PATH +echo "$PATH" diff --git a/tests/scripts/test-export.sh b/tests/scripts/test-export.sh index cb1e1c514..917349b44 100644 --- a/tests/scripts/test-export.sh +++ b/tests/scripts/test-export.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Run from the root of the project using `bash tests/test_export.sh` set -e set -x