Skip to content

Commit 0d1d6fd

Browse files
committed
ci: Format shell scripts
Set up `shfmt` configuration and apply it to our shell scripts with the following: fd -e sh -x shfmt -w
1 parent e3acb8a commit 0d1d6fd

File tree

8 files changed

+59
-53
lines changed

8 files changed

+59
-53
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*.sh]
2+
# See https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#examples
3+
indent_style = space
4+
indent_size = 4
5+
6+
switch_case_indent = true
7+
space_redirects = true

ci/android-install-sdk.sh

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ wget -q --tries=20 "https://dl.google.com/android/repository/commandlinetools-li
1515
unzip -q -d sdk/cmdline-tools "commandlinetools-linux-${sdk}_latest.zip"
1616

1717
case "$1" in
18-
arm | armv7)
19-
api=24
20-
image="system-images;android-${api};default;armeabi-v7a"
21-
;;
22-
aarch64)
23-
api=24
24-
image="system-images;android-${api};google_apis;arm64-v8a"
25-
;;
26-
i686)
27-
api=28
28-
image="system-images;android-${api};default;x86"
29-
;;
30-
x86_64)
31-
api=28
32-
image="system-images;android-${api};default;x86_64"
33-
;;
34-
*)
35-
echo "invalid arch: $1"
36-
exit 1
37-
;;
38-
esac;
18+
arm | armv7)
19+
api=24
20+
image="system-images;android-${api};default;armeabi-v7a"
21+
;;
22+
aarch64)
23+
api=24
24+
image="system-images;android-${api};google_apis;arm64-v8a"
25+
;;
26+
i686)
27+
api=28
28+
image="system-images;android-${api};default;x86"
29+
;;
30+
x86_64)
31+
api=28
32+
image="system-images;android-${api};default;x86_64"
33+
;;
34+
*)
35+
echo "invalid arch: $1"
36+
exit 1
37+
;;
38+
esac
3939

4040
# Try to fix warning about missing file.
4141
# See https://askubuntu.com/a/1078784
@@ -53,9 +53,9 @@ echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg
5353
# which produces an insane amount of output.
5454
yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
5555
yes | ./sdk/cmdline-tools/tools/bin/sdkmanager --no_https \
56-
"platform-tools" \
57-
"platforms;android-${api}" \
58-
"${image}" | grep -v = || true
56+
"platform-tools" \
57+
"platforms;android-${api}" \
58+
"${image}" | grep -v = || true
5959

6060
# The newer emulator versions (31.3.12 or higher) fail to a valid AVD and the test gets stuck.
6161
# Until we figure out why, we use the older version (31.3.11).

ci/install-musl.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ case ${1} in
2525
musl_arch=aarch64
2626
kernel_arch=arm64
2727
CC=aarch64-linux-gnu-gcc \
28-
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
28+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
2929
make install -j4
3030
;;
3131
arm)
3232
musl_arch=arm
3333
kernel_arch=arm
3434
CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \
35-
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
35+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
3636
make install -j4
3737
;;
3838
i686)
@@ -43,7 +43,7 @@ case ${1} in
4343
# Specifically pass -m32 in CFLAGS and override CC when running
4444
# ./configure, since otherwise the script will fail to find a compiler.
4545
CC=gcc CFLAGS="-m32" \
46-
./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686
46+
./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686
4747
# unset CROSS_COMPILE when running make; otherwise the makefile will
4848
# call the non-existent binary 'i686-ar'.
4949
make CROSS_COMPILE= install -j4
@@ -58,21 +58,21 @@ case ${1} in
5858
musl_arch=s390x
5959
kernel_arch=s390
6060
CC=s390x-linux-gnu-gcc \
61-
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
61+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
6262
make install -j4
6363
;;
6464
loongarch64)
6565
musl_arch=loongarch64
6666
kernel_arch=loongarch
6767
CC=loongarch64-linux-gnu-gcc-14 \
68-
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
68+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
6969
make install -j4
7070
;;
7171
powerpc64*)
7272
musl_arch=powerpc64
7373
kernel_arch=powerpc
7474
CC="${1}-linux-gnu-gcc" CFLAGS="-mlong-double-64" \
75-
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
75+
./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes
7676
make install -j4
7777
;;
7878
*)
@@ -81,7 +81,6 @@ case ${1} in
8181
;;
8282
esac
8383

84-
8584
# shellcheck disable=SC2103
8685
cd ..
8786
rm -rf "$musl"
@@ -123,8 +122,8 @@ EOF
123122
base=$(basename "$url")
124123
curl --retry 5 -L "$url" > "$base"
125124
case $base in
126-
linux-*) kernel=$base;;
127-
patch-*) patch=$base;;
125+
linux-*) kernel=$base ;;
126+
patch-*) patch=$base ;;
128127
esac
129128
# Check if file is known
130129
grep -o "$base" alpine-sha512sums

ci/install-rust.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ toolchain="${TOOLCHAIN:-nightly}"
99
os="${OS:-}"
1010

1111
case "$(uname -s)" in
12-
Linux*) os=linux ;;
13-
Darwin*) os=macos ;;
14-
MINGW*) os=windows ;;
12+
Linux*) os=linux ;;
13+
Darwin*) os=macos ;;
14+
MINGW*) os=windows ;;
1515
*)
1616
echo "Unknown system $(uname -s)"
1717
exit 1
@@ -51,7 +51,7 @@ if [ "$os" = "windows" ]; then
5151

5252
if [ -n "${ARCH_BITS:-}" ]; then
5353
echo "Fix MinGW"
54-
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
54+
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a; do
5555
cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
5656
done
5757
fi
@@ -71,6 +71,6 @@ until [ $n -ge $N ]; do
7171
break
7272
fi
7373

74-
n=$((n+1))
74+
n=$((n + 1))
7575
sleep 1
7676
done

ci/run-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo "${HOME}"
2121
pwd
2222

2323
# Avoid "no space left on device" failure if running in CI
24-
if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ] ; then
24+
if [ "${CI:-0}" != "0" ] && [ "$target" = "aarch64-linux-android" ]; then
2525
docker system prune -af
2626
docker system df
2727
fi

ci/run.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ case "$target" in
1919
*android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
2020
*s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;;
2121
# For all other platforms, test everything in the workspace
22-
*) cmd="$cmd --workspace"
22+
*) cmd="$cmd --workspace" ;;
2323
esac
2424

2525
# garando_errors only compiles on `cfg(any(unix, windows))`
2626
case "$target" in
27-
*wasm*) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next"
27+
*wasm*) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;;
2828
esac
2929

3030
if [ "$target" = "s390x-unknown-linux-gnu" ]; then
@@ -37,13 +37,13 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then
3737
if [ "$passed" = "0" ]; then
3838
# shellcheck disable=SC2086
3939
if $cmd --no-default-features -- $test_flags; then
40-
passed=$((passed+1))
40+
passed=$((passed + 1))
4141
continue
4242
fi
4343
elif [ "$passed" = "1" ]; then
4444
# shellcheck disable=SC2086
4545
if $cmd -- $test_flags; then
46-
passed=$((passed+1))
46+
passed=$((passed + 1))
4747
continue
4848
fi
4949
elif [ "$passed" = "2" ]; then
@@ -52,7 +52,7 @@ if [ "$target" = "s390x-unknown-linux-gnu" ]; then
5252
break
5353
fi
5454
fi
55-
n=$((n+1))
55+
n=$((n + 1))
5656
sleep 1
5757
done
5858
else

ci/style.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export LC_ALL=C
6565

6666
for file in libc-test/semver/*.txt; do
6767
case "$file" in
68-
*TODO*) continue ;;
68+
*TODO*) continue ;;
6969
esac
7070

7171
if ! sort -C "$file"; then
@@ -82,7 +82,7 @@ for file in libc-test/semver/*.txt; do
8282
fi
8383
done
8484

85-
if shellcheck --version ; then
85+
if shellcheck --version; then
8686
find . -name '*.sh' -print0 | xargs -0 shellcheck
8787
else
8888
echo "shellcheck not found"

ci/verify-build.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ filter="${FILTER:-}"
1414
host_target=$(rustc -vV | awk '/^host/ { print $2 }')
1515

1616
case "$(uname -s)" in
17-
Linux*) os=linux ;;
18-
Darwin*) os=macos ;;
19-
MINGW*) os=windows ;;
17+
Linux*) os=linux ;;
18+
Darwin*) os=macos ;;
19+
MINGW*) os=windows ;;
2020
*)
2121
echo "Unknown system $(uname -s)"
2222
exit 1
@@ -25,7 +25,7 @@ esac
2525

2626
echo "Testing Rust $rust on $os"
2727

28-
if [ "$TOOLCHAIN" = "nightly" ] ; then
28+
if [ "$TOOLCHAIN" = "nightly" ]; then
2929
# For build-std
3030
rustup component add rust-src
3131
fi
@@ -61,10 +61,10 @@ test_target() {
6161
N=5
6262
n=0
6363
until [ $n -ge $N ]; do
64-
if rustup target add "$target" --toolchain "$rust" ; then
64+
if rustup target add "$target" --toolchain "$rust"; then
6565
break
6666
fi
67-
n=$((n+1))
67+
n=$((n + 1))
6868
sleep 1
6969
done
7070
fi
@@ -77,7 +77,7 @@ test_target() {
7777
# Test with the equivalent of __USE_TIME_BITS64
7878
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
7979
case "$target" in
80-
arm*-gnu*|i*86*-gnu|powerpc-*-gnu*|mips*-gnu|sparc-*-gnu|thumb-*gnu*)
80+
arm*-gnu* | i*86*-gnu | powerpc-*-gnu* | mips*-gnu | sparc-*-gnu | thumb-*gnu*)
8181
# Test with the equivalent of _FILE_OFFSET_BITS=64
8282
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd
8383
# Test with the equivalent of _TIME_BITS=64

0 commit comments

Comments
 (0)