Skip to content

Commit ad7f0b1

Browse files
committed
Format installation script
Using the default configuration of shfmt.
1 parent e3fac4b commit ad7f0b1

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

.github/workflows/check-formatting.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ jobs:
3939
- name: Check Go code formatting
4040
run: task go:check-formatting
4141

42+
- name: Check shell script formatting
43+
# https://github.com/mvdan/sh
44+
run: |
45+
docker run --volume "$GITHUB_WORKSPACE/libraries/spell-check":/mnt --workdir /mnt mvdan/shfmt:latest -w .
46+
git diff --color --exit-code
47+
4248
- name: Check documentation formatting
4349
run: task docs:check-formatting
4450

Taskfile.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ tasks:
203203
cmds:
204204
- npx {{ .PRETTIER }} --write "**/*.md"
205205

206+
shell:check-formatting:
207+
desc: Format shell scripts
208+
cmds:
209+
# https://github.com/mvdan/sh#shfmt
210+
- shfmt -d .
211+
212+
shell:format:
213+
desc: Format shell scripts
214+
cmds:
215+
- shfmt -l -w .
216+
206217
config:check:
207218
desc: Lint and check formatting of configuration files
208219
cmds:

install.sh

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ initDestination() {
3333
LBINDIR="$BINDIR"
3434
else
3535
if [ ! -d "$DEFAULT_BINDIR" ]; then
36-
mkdir "$DEFAULT_BINDIR"
36+
mkdir "$DEFAULT_BINDIR"
3737
fi
3838
LBINDIR="$DEFAULT_BINDIR"
3939
fi
@@ -43,33 +43,33 @@ initDestination() {
4343
initArch() {
4444
ARCH=$(uname -m)
4545
case $ARCH in
46-
armv5*) ARCH="armv5";;
47-
armv6*) ARCH="ARMv6";;
48-
armv7*) ARCH="ARMv7";;
49-
aarch64) ARCH="ARM64";;
50-
x86) ARCH="32bit";;
51-
x86_64) ARCH="64bit";;
52-
i686) ARCH="32bit";;
53-
i386) ARCH="32bit";;
46+
armv5*) ARCH="armv5" ;;
47+
armv6*) ARCH="ARMv6" ;;
48+
armv7*) ARCH="ARMv7" ;;
49+
aarch64) ARCH="ARM64" ;;
50+
x86) ARCH="32bit" ;;
51+
x86_64) ARCH="64bit" ;;
52+
i686) ARCH="32bit" ;;
53+
i386) ARCH="32bit" ;;
5454
esac
5555
echo "ARCH=$ARCH"
5656
}
5757

5858
initOS() {
5959
OS=$(uname -s)
6060
case "$OS" in
61-
Linux*) OS='Linux' ;;
62-
Darwin*) OS='macOS' ;;
63-
MINGW*) OS='Windows';;
64-
MSYS*) OS='Windows';;
61+
Linux*) OS='Linux' ;;
62+
Darwin*) OS='macOS' ;;
63+
MINGW*) OS='Windows' ;;
64+
MSYS*) OS='Windows' ;;
6565
esac
6666
echo "OS=$OS"
6767
}
6868

6969
initDownloadTool() {
70-
if type "curl" > /dev/null; then
70+
if type "curl" >/dev/null; then
7171
DOWNLOAD_TOOL="curl"
72-
elif type "wget" > /dev/null; then
72+
elif type "wget" >/dev/null; then
7373
DOWNLOAD_TOOL="wget"
7474
else
7575
fail "You need curl or wget as download tool. Please install it first before continuing"
@@ -106,7 +106,7 @@ get() {
106106
body=$(echo "$httpResponse" | sed -e 's/HTTPSTATUS\:.*//g')
107107
elif [ "$DOWNLOAD_TOOL" = "wget" ]; then
108108
tmpFile=$(mktemp)
109-
body=$(wget --server-response --content-on-error -q -O - "$url" 2> $tmpFile || true)
109+
body=$(wget --server-response --content-on-error -q -O - "$url" 2>$tmpFile || true)
110110
httpStatusCode=$(cat $tmpFile | awk '/^ HTTP/{print $2}')
111111
fi
112112
if [ "$httpStatusCode" != 200 ]; then
@@ -203,7 +203,6 @@ testVersion() {
203203
echo "$ARDUINO_LINT_VERSION installed successfully in $LBINDIR"
204204
}
205205

206-
207206
# Execution
208207

209208
#Stop execution on any error

0 commit comments

Comments
 (0)