Skip to content

Commit 3ebe7ee

Browse files
apacheGH-46909: [CI][Dev] Fix shellcheck errors in the ci/scripts/install_sccache.sh (apache#46910)
### Rationale for this change This is the sub issue apache#44748. ``` shellcheck ci/scripts/install_sccache.sh In ci/scripts/install_sccache.sh line 22: if [ "$#" -lt 1 -o "$#" -gt 3 ]; then ^-- SC2166 (warning): Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. In ci/scripts/install_sccache.sh line 42: curl -L $SCCACHE_URL --output $SCCACHE_ARCHIVE ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: curl -L "$SCCACHE_URL" --output $SCCACHE_ARCHIVE In ci/scripts/install_sccache.sh line 43: curl -L $SCCACHE_URL.sha256 --output $SCCACHE_ARCHIVE.sha256 ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: curl -L "$SCCACHE_URL".sha256 --output $SCCACHE_ARCHIVE.sha256 In ci/scripts/install_sccache.sh line 53: sha256sum $SHA_ARGS $SCCACHE_ARCHIVE.sha256 ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: sha256sum "$SHA_ARGS" $SCCACHE_ARCHIVE.sha256 In ci/scripts/install_sccache.sh line 55: if [ ! -d $PREFIX ]; then ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: if [ ! -d "$PREFIX" ]; then In ci/scripts/install_sccache.sh line 56: mkdir -p $PREFIX ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: mkdir -p "$PREFIX" In ci/scripts/install_sccache.sh line 61: tar -xzvf $SCCACHE_ARCHIVE --strip-component=1 --directory $PREFIX --exclude="sccache*/*E*E*" ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: tar -xzvf $SCCACHE_ARCHIVE --strip-component=1 --directory "$PREFIX" --exclude="sccache*/*E*E*" In ci/scripts/install_sccache.sh line 62: chmod a+x $PREFIX/sccache ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: chmod a+x "$PREFIX"/sccache In ci/scripts/install_sccache.sh line 65: echo "$PREFIX" >> $GITHUB_PATH ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo "$PREFIX" >> "$GITHUB_PATH" In ci/scripts/install_sccache.sh line 67: echo "SCCACHE_PATH=$PREFIX/sccache.exe" >> $GITHUB_ENV ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo "SCCACHE_PATH=$PREFIX/sccache.exe" >> "$GITHUB_ENV" For more information: https://www.shellcheck.net/wiki/SC2166 -- Prefer [ p ] || [ q ] as [ p -o q... https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... ``` ### What changes are included in this PR? * SC2086: Use multiple tests. * SC2086: Quoting variables. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: apache#46909 Authored-by: Hiroyuki Sato <hiroysato@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 0b34e6b commit 3ebe7ee

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ repos:
325325
?^ci/scripts/install_numpy\.sh$|
326326
?^ci/scripts/install_pandas\.sh$|
327327
?^ci/scripts/install_python\.sh$|
328+
?^ci/scripts/install_sccache\.sh$|
328329
?^ci/scripts/install_spark\.sh$|
329330
?^ci/scripts/install_vcpkg\.sh$|
330331
?^ci/scripts/integration_arrow_build\.sh$|

ci/scripts/install_sccache.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
set -e
2121

22-
if [ "$#" -lt 1 -o "$#" -gt 3 ]; then
22+
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
2323
echo "Usage: $0 <build> <prefix> <version>"
2424
echo "Will default to version=0.3.0 "
2525
exit 1
@@ -39,30 +39,30 @@ SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v$VERSION/scca
3939
SCCACHE_ARCHIVE=sccache.tar.gz
4040

4141
# Download archive and checksum
42-
curl -L $SCCACHE_URL --output $SCCACHE_ARCHIVE
43-
curl -L $SCCACHE_URL.sha256 --output $SCCACHE_ARCHIVE.sha256
42+
curl -L "$SCCACHE_URL" --output $SCCACHE_ARCHIVE
43+
curl -L "${SCCACHE_URL}.sha256" --output $SCCACHE_ARCHIVE.sha256
4444
echo " $SCCACHE_ARCHIVE" >> $SCCACHE_ARCHIVE.sha256
4545

46-
SHA_ARGS="--check --status"
46+
SHA_ARGS=(--check --status)
4747

4848
# Busybox sha256sum uses different flags
4949
if sha256sum --version 2>&1 | grep -q BusyBox; then
50-
SHA_ARGS="-sc"
50+
SHA_ARGS=(-sc)
5151
fi
5252

53-
sha256sum $SHA_ARGS $SCCACHE_ARCHIVE.sha256
53+
sha256sum "${SHA_ARGS[@]}" $SCCACHE_ARCHIVE.sha256
5454

55-
if [ ! -d $PREFIX ]; then
56-
mkdir -p $PREFIX
55+
if [ ! -d "$PREFIX" ]; then
56+
mkdir -p "$PREFIX"
5757
fi
5858

5959
# Extract only the sccache binary into $PREFIX and ignore README and LICENSE.
6060
# --wildcards doesn't work on busybox.
61-
tar -xzvf $SCCACHE_ARCHIVE --strip-component=1 --directory $PREFIX --exclude="sccache*/*E*E*"
62-
chmod a+x $PREFIX/sccache
61+
tar -xzvf $SCCACHE_ARCHIVE --strip-component=1 --directory "$PREFIX" --exclude="sccache*/*E*E*"
62+
chmod a+x "${PREFIX}/sccache"
6363

6464
if [ -n "${GITHUB_PATH}" ]; then
65-
echo "$PREFIX" >> $GITHUB_PATH
65+
echo "$PREFIX" >> "$GITHUB_PATH"
6666
# Add executable for windows as mingw workaround.
67-
echo "SCCACHE_PATH=$PREFIX/sccache.exe" >> $GITHUB_ENV
67+
echo "SCCACHE_PATH=$PREFIX/sccache.exe" >> "$GITHUB_ENV"
6868
fi

0 commit comments

Comments
 (0)