forked from RedisGears/RedisGears
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getver
executable file
·34 lines (28 loc) · 727 Bytes
/
getver
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
#!/bin/bash
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
getver_c=$(mktemp "${TMPDIR:-/tmp}/getver-XXXXXXX.c")
if [[ $NUMERIC != 1 ]]; then
cat <<- EOF > $getver_c
#include <stdio.h>
#include "src/version.h"
int main(int argc, char *argv[]) {
printf("%d.%d.%d\n", REDISGEARS_VERSION_MAJOR, REDISGEARS_VERSION_MINOR, REDISGEARS_VERSION_PATCH);
return 0;
}
EOF
else
cat <<- EOF > $getver_c
#include <stdio.h>
#include "src/version.h"
int main(int argc, char *argv[]) {
printf("%d\n", REDISGEARS_MODULE_VERSION);
return 0;
}
EOF
fi
prog=$(mktemp "${TMPDIR:-/tmp}/getver.XXXXXXX")
gcc -I$HERE -o $prog $getver_c
ver=`$prog`
rm -f $prog $getver_c
echo $ver
exit 0