Skip to content

Commit

Permalink
scripts/version: fix on macOS
Browse files Browse the repository at this point in the history
The following fails when trying to run on macOS (simplified):

    version='0.0.0'
    expr match "${version}" '^v'
    # expr: syntax error

This changes the script to work with different sh syntax.
  • Loading branch information
GodTamIt authored Nov 12, 2024
1 parent f67adba commit 6ad4d17
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ if [ $(git describe --tags --exact-match --match 'v[0-9]*.[0-9]*.[0-9]*' &>/dev/
version=$(git describe --tags --exact-match --match 'v[0-9]*.[0-9]*.[0-9]*')
fi

if [ $(expr match "${version}" '^v') -eq 1 ]; then
printf '%s\n' $(expr substr "${version}" 2 $(expr length "${version}"))
else
printf '%s\n' "${version}"
fi
case "$version" in
v*) echo "${version#v}" ;;
*) echo "$version" ;;
esac

0 comments on commit 6ad4d17

Please sign in to comment.