Skip to content

Commit

Permalink
fix(install/linux): properly parse --root flag and tag option (spic…
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri authored Apr 6, 2024
1 parent 6dbc53c commit 1d9de3a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@

set -e

while getopts ":r" arg; do
case "${arg}" in
"r") override_root=1 ;;
*) echo "Invalid option -${OPTARG}" >&2; exit 1 ;;
for arg in "$@"; do
shift
case "$arg" in
"--root") override_root=1 ;;
*)
if echo "$arg" | grep -qv "^-"; then
tag="$arg"
else
echo "Invalid option $arg" >&2
exit 1
fi
esac
done

Expand All @@ -19,7 +26,7 @@ is_root() {
if ! is_root && [ "${override_root:-0}" -eq 0 ]; then
echo "The script was ran as root. Script will now exit"
echo "If you did not intend to do this, please run the script without root permissions to avoid issues with Spicetify"
echo "You can override this behavior by passing '-r' or '--root' flag to this script"
echo "You can override this behavior by passing '--root' flag to this script"
exit
fi

Expand All @@ -46,9 +53,7 @@ command -v grep >/dev/null || { log "grep isn't installed!" >&2; exit 1; }

# download uri
releases_uri=https://github.com/spicetify/spicetify-cli/releases
if [ $# -gt 0 ]; then
tag=$1
else
if [ -z "$tag" ]; then
tag=$(curl -LsH 'Accept: application/json' $releases_uri/latest)
tag=${tag%\,\"update_url*}
tag=${tag##*tag_name\":\"}
Expand Down

0 comments on commit 1d9de3a

Please sign in to comment.