]> git.ipfire.org Git - thirdparty/systemd.git/blob - tools/check-version.sh
Merge pull request #32324 from mrc0mmand/more-website-fixes
[thirdparty/systemd.git] / tools / check-version.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 set -eu
4 set -o pipefail
5
6 # Note: 'grep ... >/dev/null' instead of just 'grep -q' is used intentionally
7 # here, since 'grep -q' exits on the first match causing SIGPIPE being
8 # sent to the sender.
9
10 BINARY="${1:?}"
11 VERSION="${2:?}"
12 export SYSTEMD_LOG_LEVEL=info
13
14 if [[ ! -x "$BINARY" ]]; then
15 echo "$BINARY is not an executable"
16 exit 1
17 fi
18
19 # --version prints something. Also catches case where args are ignored.
20 if ! "$BINARY" --version | grep . >/dev/null; then
21 echo "$(basename "$BINARY") --version output is empty"
22 exit 2
23 fi
24
25 # no --version output to stderr
26 if "$BINARY" --version 2>&1 1>/dev/null | grep .; then
27 echo "$(basename "$BINARY") --version prints to stderr"
28 exit 3
29 fi
30
31 # project version appears in version output
32 out="$("$BINARY" --version)"
33 if ! grep -F "$VERSION" >/dev/null <<<"$out"; then
34 echo "$(basename "$BINARY") --version output does not match '$VERSION': $out"
35 exit 4
36 fi