Skip to content

Commit

Permalink
Fix shellcheck in style.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
qhdwight committed Sep 20, 2024
1 parent fdd738b commit 4b26006
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions ansible/roles/build/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- curl
- unzip
- rsync
- shellcheck
- python3-pip
- python3-dev
- python3-venv
Expand Down
6 changes: 3 additions & 3 deletions starter_project/autonomy/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ function print_update_error() {
}

function find_executable() {
local readonly executable="$1"
local readonly version="$2"
local readonly path=$(which "${executable}")
local -r executable="$1"
local -r version="$2"
local -r path=$(which "${executable}")
if [ ! -x "${path}" ]; then
echo -e "${RED}[Error] Could not find ${executable}${NC}"
print_update_error
Expand Down
6 changes: 3 additions & 3 deletions starter_project/autonomy/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function print_update_error() {
}

function find_executable() {
local readonly executable="$1"
local readonly version="$2"
local readonly path=$(which "${executable}")
local -r executable="$1"
local -r version="$2"
local -r path=$(which "${executable}")
if [ ! -x "${path}" ]; then
echo -e "${RED}[Error] Could not find ${executable}${NC}"
print_update_error
Expand Down
2 changes: 1 addition & 1 deletion starter_project/teleop/gui_starter_frontend.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

cd basestation_gui/frontend
cd basestation_gui/frontend || exit 1
bun run watch
15 changes: 8 additions & 7 deletions style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# See: https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuo pipefail

# Prevent globbing from failing if no files match
shopt -s nullglob
shopt -s nullglob globstar
GLOBIGNORE="./venv/**"

readonly RED='\033[0;31m'
readonly NC='\033[0m'
Expand Down Expand Up @@ -86,11 +86,12 @@ echo "Linting Python with mypy ..."
if command -v shellcheck &> /dev/null; then
echo
echo "Linting bash scripts with shellcheck ..."
readonly SHELL_FILES=$(find . -depth 1 -name "*.sh")
for file in $SHELL_FILES; do
# SC2155 is separate declaration and command.
shellcheck "${file}" --exclude=SC2155
done
readonly SHELL_FILES=(
./**/*.sh
)
# SC2155 is separate declaration and command.
shellcheck --exclude=SC2155 "${SHELL_FILES[@]}"
echo "Done"
fi

if [ $# -eq 0 ] || [ "$1" != "--fix" ]; then
Expand Down

0 comments on commit 4b26006

Please sign in to comment.