Skip to content

Commit

Permalink
Use some handy bash-isms in version check script
Browse files Browse the repository at this point in the history
The script is nonportable to other shells already because of its
use of trap (and other features, such as implicit assumptions made
about echo, and the function keyword), which its hashbang already
clearly conveys.

This uses:

- $(<X) in place of $(cat X), to have the shell read the file
  directly rather than using cat.

- printf -v in one place to set a variable rather than printing.
  This eliminates a command substitution that was harder to read.
  • Loading branch information
EliahKagan committed Oct 3, 2023
1 parent 0920371 commit e973f52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions check-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readonly changes_path='doc/source/changes.rst'

function get_latest_tag() {
local config_opts
config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)"
printf -v config_opts ' -c versionsort.suffix=-%s' alpha beta pre rc RC
# shellcheck disable=SC2086 # Deliberately word-splitting the arguments.
git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1
}
Expand All @@ -31,7 +31,7 @@ echo 'Checking that ALL changes are committed.'
git status -s --ignore-submodules
test -z "$(git status -s --ignore-submodules)"

version_version="$(cat "$version_path")"
version_version="$(<"$version_path")"
changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")"
latest_tag="$(get_latest_tag)"
head_sha="$(git rev-parse HEAD)"
Expand Down

0 comments on commit e973f52

Please sign in to comment.