Skip to content

Commit

Permalink
Declare and assign variable separately in setup script
Browse files Browse the repository at this point in the history
Coverage of `readonly` was added to ShellCheck rule SC2155:

https://github.com/koalaman/shellcheck/wiki/SC2155#problematic-code-in-the-case-of-readonly

> ### Problematic code in the case of `readonly`:
>
> ```sh
> readonly foo="$(mycmd)"
> ```
>
> #### Correct code:
>
> ```sh
> foo="$(mycmd)"
> readonly foo
> ```

There was this sort of "problematic code" in the action setup script, which caused the "Lint shell scripts" CI workflow
to start failing after the 0.7.2 release of ShellCheck.

The script's usage of `readonly` is now adjusted according to ShellCheck's recommendation.
  • Loading branch information
per1234 committed Mar 25, 2022
1 parent afbfe52 commit 2613632
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion action-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
readonly PYTHON_PACKAGE_VERSION='3.8'

# https://stackoverflow.com/a/29835459
readonly SCRIPT_PATH="$(
SCRIPT_PATH="$(
CDPATH='' \
cd -- "$(
dirname -- "$0"
)" && (
pwd -P
)
)"
readonly SCRIPT_PATH

readonly PYTHON_COMMAND="python${PYTHON_PACKAGE_VERSION}"
readonly PYTHON_VENV_PATH="${SCRIPT_PATH}/compilesketches/.venv"
Expand Down

0 comments on commit 2613632

Please sign in to comment.