Skip to content

Commit e973f52

Browse files
committed
Use some handy bash-isms in version check script
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.
1 parent 0920371 commit e973f52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: check-version.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readonly changes_path='doc/source/changes.rst'
1212

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

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

0 commit comments

Comments
 (0)