Skip to content

Commit 81eff91

Browse files
committed
build.sh: add support for options
Signed-off-by: Yann Dirson <[email protected]>
1 parent e2ec286 commit 81eff91

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

build.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11
#!/usr/bin/env bash
2-
32
set -e
43

5-
if [ -z "$1" ]; then
6-
echo "Usage: $0 {version}"
7-
echo "... where {version} is a 'x.y' version such as 8.0."
8-
exit
9-
fi
4+
die() {
5+
echo >&2
6+
echo >&2 "ERROR: $*"
7+
echo >&2
8+
exit 1
9+
}
10+
11+
die_usage() {
12+
usage >&2
13+
die "$*"
14+
}
15+
16+
usage() {
17+
cat <<EOF
18+
Usage: $0 <version>
19+
... where <version> is a 'x.y' version such as 8.0.
20+
EOF
21+
}
22+
23+
while [ $# -ge 1 ]; do
24+
case "$1" in
25+
--help|-h)
26+
usage
27+
exit 0
28+
;;
29+
-*)
30+
die_usage "unknown flag '$1'"
31+
;;
32+
*)
33+
break
34+
;;
35+
esac
36+
shift
37+
done
38+
39+
[ -n "$1" ] || die_usage "version parameter missing"
1040

1141
RUNNER=""
1242
if [ -n "$XCPNG_OCI_RUNNER" ]; then

0 commit comments

Comments
 (0)