-
Notifications
You must be signed in to change notification settings - Fork 4
/
component-version.sh
executable file
·47 lines (43 loc) · 1.03 KB
/
component-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function usage() {
echo "usage: $0 [component [version] | components] "
echo
echo "Show or replace version strings with new version"
exit -1
}
COMPONENTS=($(find . -name set-version.sh))
function list_components() {
for SCRIPT in "${COMPONENTS[@]}"; do
echo "$SCRIPT"
done
}
function unknown_component() {
echo "unknown component - use one of"
list_components
exit -1
}
if (($# == 0)); then
for SCRIPT in "${COMPONENTS[@]}"; do
echo "COMPONENT: $SCRIPT"
pushd $(dirname "$SCRIPT") &> /dev/null
./"$(basename "$SCRIPT")"
popd &> /dev/null
done
elif (($# > 2)); then
usage
elif [ "$1" == "components" ]; then
list_components
else
SCRIPT=""
for COMPONENT in "${COMPONENTS[@]}"; do
if [ "$1" == "$COMPONENT" ]; then
SCRIPT="$1"
break
fi
done
if [ -z "$SCRIPT" ]; then
unknown_component
fi
pushd $(dirname "$SCRIPT") &> /dev/null
eval "./$(basename "$SCRIPT") $2"
popd &> /dev/null
fi