Skip to content

Commit 9053822

Browse files
add shellcheck
1 parent cb21576 commit 9053822

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Build
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- '**'
47

58
jobs:
69
build:

.github/workflows/shellcheck.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: ShellCheck
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
check:
10+
name: ShellCheck
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Install ShellCheck
16+
run: sudo apt-get install -y shellcheck
17+
- name: Run shellcheck
18+
run: ./shellcheck.sh

.shellcheckrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
# enable additional checks
3+
enable=add-default-case
4+
enable=avoid-nullary-conditions
5+
enable=check-set-e-suppressed
6+
enable=check-unassigned-uppercase
7+
enable=deprecate-which
8+
9+
# cd fail
10+
# this is usually covered by set -e
11+
disable=SC2164
12+
13+
# dont follow source files info
14+
# we check all shell scripts anyways
15+
disable=SC1091
16+
17+
# unnecessary arithmetic variables style
18+
# i dont care whether it says $(($TODAY)) or $((TODAY))
19+
disable=SC2004
20+
21+
# redundant sed invocation
22+
disable=SC2001

shellcheck.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
export IFS=$'\n'
3+
[ -z "$(command -v shellcheck)" ] && echo "shellcheck not installed!" && exit 1
4+
shellcheck --version
5+
6+
SHELLCHECK_ARGS=()
7+
SHELLCHECK_ARGS+=(--wiki-link-count=256)
8+
9+
declare -a FILES
10+
mapfile -t FILES < <(find . -type f -name '*.sh')
11+
12+
shellcheck \
13+
"${SHELLCHECK_ARGS[@]}" \
14+
"$@" \
15+
"${FILES[@]}"

0 commit comments

Comments
 (0)