Skip to content

Commit

Permalink
format/shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
robzr committed Mar 6, 2024
1 parent febef72 commit 24513e8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sver
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ sver_constraint() { # $1=version $2=constraint(s); if matches returns 0 else 1
version=$REPLY
shift
constraints="$*"
while [ -n "$constraints" ] && [ $return_status = 0 ] ; do
while [ -n "$constraints" ] && [ $return_status = 0 ]; do
constraint=${constraints%%,*}
constraints=${constraints#*,}
if [ "$constraint" = "$constraints" ]; then
Expand All @@ -154,14 +154,14 @@ sver_constraint() { # $1=version $2=constraint(s); if matches returns 0 else 1
return_status=1
fi
elif [ "$operator" = '!' ]; then
if [ "${value_alpha/pre*/pre}" = 'pre' ] ; then
if [ "${value_alpha/pre*/pre}" = 'pre' ]; then
sver_get_prerelease "$version"
if [ -n "$REPLY" ] ; then
if [ -n "$REPLY" ]; then
return_status=1
fi
elif [ "${value_alpha/build*/build}" = 'build' ] ; then
elif [ "${value_alpha/build*/build}" = 'build' ]; then
sver_get_build_metadata "$version"
if [ -n "$REPLY" ] ; then
if [ -n "$REPLY" ]; then
return_status=1
fi
fi
Expand Down Expand Up @@ -402,7 +402,7 @@ sver_greater_than() { # if $1 > $2 then return 0 else return 1
}

sver_help() {
# shellcheck disable=SC1079
# shellcheck disable=SC1078
echo "${SVER_INTRO}
Usage: sver <command> [<sub_command>] [<version>|<option> ...]
Expand Down Expand Up @@ -448,7 +448,7 @@ Constraints:
~> <version_substring> -- pessimistic constraint operator - least significant
(rightmost) identifier specified in the constraint matched with >=, but
more significant (further left) identifiers must be equal
!pre[release] -- does not contain a prerelease (ie: "stable")
!pre[release] -- does not contain a prerelease (ie: \"stable\")
!bui[ild_metadata] -- does not contain build_metadata
Examples: \"~> v1.2, != 1.3\", \"> 1, <= v2.5, != v2.4.4\", \"v1, !pre\""
}
Expand Down Expand Up @@ -524,7 +524,7 @@ sver_normalize() {
# no arg, input is list of semvers, output is via stdout
sver_sort() {
local filter reverse_flag one_flag
while [ "$1" = "-r" ] || [ "$1" = "-o" ] ; do
while [ "$1" = "-r" ] || [ "$1" = "-o" ]; do
if [ "$1" = "-o" ]; then
one_flag=$1
elif [ "$1" = "-r" ]; then
Expand All @@ -541,6 +541,7 @@ sver_sort() {
# shellcheck disable=SC2086
sver_filter "$filter" | sort $reverse_flag -t. -nk1 -nk2 -nk3 -k4
else
# shellcheck disable=SC2086
sver_filter "$filter" | sver_sort_bash $reverse_flag $one_flag
fi
}
Expand All @@ -552,7 +553,7 @@ sver_sort_bash() {
local comparison_function='sver_greater_than'
declare -a versions

while [ "$1" = "-r" ] || [ "$1" = "-o" ] ; do
while [ "$1" = "-r" ] || [ "$1" = "-o" ]; do
if [ "$1" = "-o" ]; then
one_flag=true
elif [ "$1" = "-r" ]; then
Expand All @@ -578,7 +579,7 @@ sver_sort_bash() {
((i++))
done

if $one_flag ; then
if $one_flag; then
echo "${versions[0]}"
else
printf '%s\n' "${versions[@]}"
Expand Down

0 comments on commit 24513e8

Please sign in to comment.