particle-os-modules/modules/fonts/download.sh
Nick Saika 17bacbe3da
fix: Fix flag ordering in set calls in scripts (#99)
The README for scripts has an incorrect use of the `set`. Where it says
to use:

	set -oue pipefail

it should be:

	set -euo pipefail

since `pipefail` is an option consumed by `set -o`.

More information: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
2024-01-16 06:12:08 +00:00

39 lines
534 B
Bash

#!/usr/bin/env bash
set -euo pipefail
NAME=$1
FORMAT=$2
URL=$3
DEST=$4
mkdir -p "$DEST"
DOWNLOAD=$(ls "$DEST" | wc -l)
FILE="$NAME.$FORMAT"
if [[ $DOWNLOAD -eq 0 ]] && [[ -n $NAME ]]; then
echo "Downloading $FILE"
curl -o "$FILE" -OL "$URL"
if [[ -f "$FILE" ]]; then
case $FORMAT in
tar.xz) tar xvJf "$FILE" -C "$DEST" ;;
zip) unzip "$FILE" -d "$DEST" ;;
esac
rm -rf "$FILE"
echo "$FILE downloaded"
else
echo "Unable to download $FILE"
fi
fi