Simplify defaults for unsupplied script arguments.

Partial #638

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-11-15 23:11:51 -05:00
parent f1a9cde9fd
commit 7a260db279
No known key found for this signature in database
4 changed files with 9 additions and 32 deletions

View file

@ -50,21 +50,13 @@ if [[ "${DRY_RUN}" == 'true' ]]; then
fi
# arg 1 - version tag
if [[ -n "${1}" ]]; then
MAS_VERSION="${1}"
else
MAS_VERSION="v$(script/version)"
fi
MAS_VERSION="${1:-"v$(script/version)"}"
echo "MAS_VERSION: ${MAS_VERSION}"
# arg 2 - revision (commit hash)
if [[ -n "${2}" ]]; then
REVISION="${2}"
else
# Derive revision from version. Fails if MAS_VERSION is not a tag.
REVISION="$(git rev-parse "${MAS_VERSION}")"
fi
# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag
REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}"
echo "REVISION: ${REVISION}"

View file

@ -20,21 +20,13 @@ if [[ "${#}" -gt 2 ]]; then
fi
# arg 1 - version tag
if [[ -n "${1}" ]]; then
MAS_VERSION="${1}"
else
MAS_VERSION="v$(script/version)"
fi
MAS_VERSION="${1:-"v$(script/version)"}"
echo "MAS_VERSION: ${MAS_VERSION}"
# arg 2 - revision (commit hash)
if [[ -n "${2}" ]]; then
REVISION="${2}"
else
# Derive revision from version. Fails if MAS_VERSION is not a tag.
REVISION="$(git rev-parse "${MAS_VERSION}")"
fi
# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag
REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}"
echo "REVISION: ${REVISION}"

View file

@ -7,11 +7,7 @@
#
# Override default prefix path with optional 1st arg
if test -n "${1}"; then
PREFIX="${1}"
else
PREFIX="$(brew --prefix)"
fi
PREFIX="${1:-"$(brew --prefix)"}"
echo "==> 🔥 Uninstalling mas from ${PREFIX}"

View file

@ -32,11 +32,8 @@ fi
MAS_VERSION="${1}"
# arg 2 - revision (commit hash)
if [[ "${#}" -ge 2 ]]; then
REVISION="${2}"
else
REVISION="$(git rev-parse "${MAS_VERSION}")"
fi
# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag
REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}"
echo "MAS_VERSION: ${MAS_VERSION}"
echo "REVISION: ${REVISION}"