Fix install.sh shellcheck warnings (#1912)
This commit is contained in:
parent
dc952f9c43
commit
6d7df19557
11
.github/workflows/ci.yaml
vendored
11
.github/workflows/ci.yaml
vendored
@ -36,11 +36,16 @@ jobs:
|
|||||||
git diff --no-ext-diff --quiet --exit-code
|
git diff --no-ext-diff --quiet --exit-code
|
||||||
./tests/completions/just.bash
|
./tests/completions/just.bash
|
||||||
|
|
||||||
- name: Check for Forbidden Words
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install ripgrep
|
sudo apt-get install ripgrep shellcheck
|
||||||
./bin/forbid
|
|
||||||
|
- name: Check for Forbidden Words
|
||||||
|
run: ./bin/forbid
|
||||||
|
|
||||||
|
- name: Check Install Script
|
||||||
|
run: shellcheck www/install.sh
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
3
justfile
3
justfile
@ -39,6 +39,9 @@ build:
|
|||||||
fmt:
|
fmt:
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
|
|
||||||
|
shellcheck:
|
||||||
|
shellcheck www/install.sh
|
||||||
|
|
||||||
man:
|
man:
|
||||||
cargo build --features help4help2man
|
cargo build --features help4help2man
|
||||||
help2man \
|
help2man \
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -eu
|
||||||
|
|
||||||
if [ ! -z ${GITHUB_ACTIONS-} ]; then
|
if [ -n "${GITHUB_ACTIONS-}" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check pipefail support in a subshell, ignore if unsupported
|
||||||
|
# shellcheck disable=SC3040
|
||||||
|
(set -o pipefail 2> /dev/null) && set -o pipefail
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Install a binary release of a just hosted on GitHub
|
Install a binary release of a just hosted on GitHub
|
||||||
@ -24,26 +28,25 @@ OPTIONS:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
git=casey/just
|
|
||||||
crate=just
|
crate=just
|
||||||
url=https://github.com/casey/just
|
url=https://github.com/casey/just
|
||||||
releases=$url/releases
|
releases=$url/releases
|
||||||
|
|
||||||
say() {
|
say() {
|
||||||
echo "install: $@" >&2
|
echo "install: $*" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
err() {
|
err() {
|
||||||
if [ ! -z ${td-} ]; then
|
if [ -n "${td-}" ]; then
|
||||||
rm -rf "$td"
|
rm -rf "$td"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
say "error: $@"
|
say "error: $*"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
need() {
|
need() {
|
||||||
if ! command -v $1 > /dev/null 2>&1; then
|
if ! command -v "$1" > /dev/null 2>&1; then
|
||||||
err "need $1 (command not found)"
|
err "need $1 (command not found)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -82,20 +85,20 @@ need mkdir
|
|||||||
need mktemp
|
need mktemp
|
||||||
need tar
|
need tar
|
||||||
|
|
||||||
if [ -z ${tag-} ]; then
|
if [ -z "${tag-}" ]; then
|
||||||
need grep
|
need grep
|
||||||
need cut
|
need cut
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${target-} ]; then
|
if [ -z "${target-}" ]; then
|
||||||
need cut
|
need cut
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${dest-} ]; then
|
if [ -z "${dest-}" ]; then
|
||||||
dest="$HOME/bin"
|
dest="$HOME/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${tag-} ]; then
|
if [ -z "${tag-}" ]; then
|
||||||
tag=$(
|
tag=$(
|
||||||
curl --proto =https --tlsv1.2 -sSf \
|
curl --proto =https --tlsv1.2 -sSf \
|
||||||
https://api.github.com/repos/casey/just/releases/latest |
|
https://api.github.com/repos/casey/just/releases/latest |
|
||||||
@ -104,12 +107,12 @@ if [ -z ${tag-} ]; then
|
|||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z ${target-} ]; then
|
if [ -z "${target-}" ]; then
|
||||||
# bash compiled with MINGW (e.g. git-bash, used in github windows runners),
|
# bash compiled with MINGW (e.g. git-bash, used in github windows runners),
|
||||||
# unhelpfully includes a version suffix in `uname -s` output, so handle that.
|
# unhelpfully includes a version suffix in `uname -s` output, so handle that.
|
||||||
# e.g. MINGW64_NT-10-0.19044
|
# e.g. MINGW64_NT-10-0.19044
|
||||||
kernel=$(uname -s | cut -d- -f1)
|
kernel=$(uname -s | cut -d- -f1)
|
||||||
uname_target="`uname -m`-$kernel"
|
uname_target="$(uname -m)-$kernel"
|
||||||
|
|
||||||
case $uname_target in
|
case $uname_target in
|
||||||
aarch64-Linux) target=aarch64-unknown-linux-musl;;
|
aarch64-Linux) target=aarch64-unknown-linux-musl;;
|
||||||
@ -119,7 +122,8 @@ if [ -z ${target-} ]; then
|
|||||||
x86_64-MINGW64_NT) target=x86_64-pc-windows-msvc;;
|
x86_64-MINGW64_NT) target=x86_64-pc-windows-msvc;;
|
||||||
x86_64-Windows_NT) target=x86_64-pc-windows-msvc;;
|
x86_64-Windows_NT) target=x86_64-pc-windows-msvc;;
|
||||||
*)
|
*)
|
||||||
err 'Could not determine target from output of `uname -m`-`uname -s`, please use `--target`:' $uname_target
|
# shellcheck disable=SC2016
|
||||||
|
err 'Could not determine target from output of `uname -m`-`uname -s`, please use `--target`:' "$uname_target"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -141,17 +145,17 @@ say "Archive: $archive"
|
|||||||
td=$(mktemp -d || mktemp -d -t tmp)
|
td=$(mktemp -d || mktemp -d -t tmp)
|
||||||
|
|
||||||
if [ "$extension" = "zip" ]; then
|
if [ "$extension" = "zip" ]; then
|
||||||
curl --proto =https --tlsv1.2 -sSfL $archive > $td/just.zip
|
curl --proto =https --tlsv1.2 -sSfL "$archive" > "$td/just.zip"
|
||||||
unzip -d $td $td/just.zip
|
unzip -d "$td" "$td/just.zip"
|
||||||
else
|
else
|
||||||
curl --proto =https --tlsv1.2 -sSfL $archive | tar -C $td -xz
|
curl --proto =https --tlsv1.2 -sSfL "$archive" | tar -C "$td" -xz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$dest/just" ] && [ $force = false ]; then
|
if [ -e "$dest/just" ] && [ "$force" = false ]; then
|
||||||
err "\`$dest/just\` already exists"
|
err "\`$dest/just\` already exists"
|
||||||
else
|
else
|
||||||
mkdir -p $dest
|
mkdir -p "$dest"
|
||||||
install -m 755 "$td/just" $dest
|
install -m 755 "$td/just" "$dest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf $td
|
rm -rf "$td"
|
||||||
|
Loading…
Reference in New Issue
Block a user