Skip to content

Commit 1bde67f

Browse files
committed
feat: add shellcheck ci check
This was mentioned in some older PR.
1 parent fdaca2c commit 1bde67f

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
FILES: "${{ steps.files.outputs.added_modified }}"
3939
- name: Lint and format Python with Ruff
4040
uses: astral-sh/ruff-action@v2
41+
- name: Shellcheck
42+
run: shellcheck --severity=error bin/* ./*.sh
4143

4244
typo:
4345
runs-on: ubuntu-latest

bin/git-create-branch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ then
3939
REMOTE=origin
4040
fi
4141

42-
test -z $BRANCH && echo "branch argument required." 1>&2 && exit 1
42+
test -z "$BRANCH" && echo "branch argument required." 1>&2 && exit 1
4343

4444
if [[ -n $REMOTE ]]
4545
then

bin/git-fork

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ else
6161
# clone forked repo into current dir
6262
git clone "${remote_prefix}${user}/${project}.git" "$project"
6363
# add reference to origin fork so can merge in upstream changes
64-
cd "$project"
64+
cd "$project" || exit
6565
git remote add upstream "${remote_prefix}${owner}/${project}.git"
6666
git fetch upstream
6767
fi

bin/git-guilt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ do
3131
esac
3232
done
3333

34-
cd "$(git-root)" # cd for git blame
34+
cd "$(git-root)" || exit # cd for git blame
3535
MERGED_LOG=$(git_extra_mktemp)
3636
if [[ $EMAIL == '-e' ]]
3737
then
@@ -44,10 +44,10 @@ for file in $(git diff --name-only "$@")
4444
do
4545
test -n "$DEBUG" && echo "git blame $file"
4646
# $1 - since $2 - until
47-
git blame $NOT_WHITESPACE --line-porcelain "$1" -- "$file" 2> /dev/null |
47+
git blame "$NOT_WHITESPACE" --line-porcelain "$1" -- "$file" 2> /dev/null |
4848
LC_ALL=C sed -n "$PATTERN" | sort | uniq -c | LC_ALL=C sed 's/^\(.\)/- \1/' >> "$MERGED_LOG"
4949
# if $2 not given, use current commit as "until"
50-
git blame $NOT_WHITESPACE --line-porcelain "${2-@}" -- "$file" 2> /dev/null |
50+
git blame "$NOT_WHITESPACE" --line-porcelain "${2-@}" -- "$file" 2> /dev/null |
5151
LC_ALL=C sed -n "$PATTERN" | sort | uniq -c | LC_ALL=C sed 's/^\(.\)/+ \1/' >> "$MERGED_LOG"
5252
done
5353

@@ -71,7 +71,7 @@ END {
7171
printf("%d %s\n", contributors[people], people)
7272
}
7373
}
74-
}' $MERGED_LOG | sort -nr | # only gawk supports built-in sort function
74+
}' "$MERGED_LOG" | sort -nr | # only gawk supports built-in sort function
7575
while read -r line
7676
do
7777
people=${line#* }
@@ -103,7 +103,7 @@ do
103103
do
104104
printf "-"
105105
done
106-
printf "(%s)" $num
106+
printf "(%s)" "$num"
107107
else
108108
for (( i = 0; i > num; i-- ))
109109
do

bin/git-obliterate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ then
1919
else
2020
# don't quote $range so that we can forward multiple rev-list arguments
2121
git filter-branch -f --index-filter "git rm -r --cached ""$file"" --ignore-unmatch" \
22-
--prune-empty --tag-name-filter cat -- $range
22+
--prune-empty --tag-name-filter cat -- "$range"
2323
fi

bin/git-repl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ while true; do
4444
esac
4545

4646
if [[ $cmd == !* ]]; then
47-
eval ${cmd:1}
47+
eval "${cmd:1}"
4848
elif [[ $cmd == git* ]]; then
49-
eval $cmd
49+
eval "$cmd"
5050
else
5151
eval git "$cmd"
5252
fi

bin/git-scp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function php_lint()
5959

6060
function _dos2unix()
6161
{
62-
command -v dos2unix > /dev/null && dos2unix $@
62+
command -v dos2unix > /dev/null && dos2unix "$@"
6363
return 0
6464
}
6565

@@ -68,8 +68,8 @@ function _sanitize()
6868
git config --get-all extras.scp.sanitize | while read -r i
6969
do
7070
case $i in
71-
php_lint) php_lint $@;; # git config --global --add extras.scp.sanitize php_lint
72-
dos2unix) _dos2unix $@;; # git config --global --add extras.scp.sanitize dos2unix
71+
php_lint) php_lint "$@";; # git config --global --add extras.scp.sanitize php_lint
72+
dos2unix) _dos2unix "$@";; # git config --global --add extras.scp.sanitize dos2unix
7373
esac
7474
done
7575
return $?
@@ -108,10 +108,10 @@ function scp_and_stage
108108
then
109109
local _TMP=${0///}
110110
echo "$list" > "$_TMP" &&
111-
_sanitize $list &&
111+
_sanitize "$list" &&
112112
_info "Pushing to $remote ($(git config "remote.$remote.url"))" &&
113113
rsync -rlDv --files-from="$_TMP" ./ "$(git config "remote.$remote.url")/" &&
114-
git add --force $list &&
114+
git add --force "$list" &&
115115
rm "$_TMP"
116116
fi
117117

@@ -131,7 +131,7 @@ function reverse_scp()
131131
shift
132132

133133
local _TMP=${0///}
134-
echo $@ > "$_TMP" &&
134+
echo "$@" > "$_TMP" &&
135135
rsync -rlDv --files-from="$_TMP" "$(git config "remote.$remote.url")/" ./ &&
136136
rm "$_TMP"
137137
}
@@ -173,8 +173,8 @@ case $(basename "$0") in
173173
git-scp)
174174
case $1 in
175175
''|-h|'?'|help|--help) shift; _test_git_scp; _usage "$@";;
176-
*) scp_and_stage $@;;
176+
*) scp_and_stage "$@";;
177177
esac
178178
;;
179-
git-rscp) reverse_scp $@;;
179+
git-rscp) reverse_scp "$@";;
180180
esac

0 commit comments

Comments
 (0)