@cryptotaxi247 / kubo / commits / a2c41e650

test/bin: add checkflags to detect flag changes

This script can be used in a Makefile to detect flag changes and to save the new flags in a file. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Apr 6, 2015 at 17:52 UTC a2c41e650da5e303a5d27a587b5699fe9ea0db90
1 file changed +23
test/bin/checkflags new
+23
@@ -0,0 +1,23 @@
1 +#!/bin/sh
2 +# Author: Christian Couder <chriscool@tuxfamily.org>
3 +# MIT LICENSED
4 +
5 +if test "$#" -lt 3
6 +then
7 + echo >&2 "usage $0 FILE VALUES MSG..."
8 + exit 1
9 +fi
10 +
11 +FLAG_FILE="$1"
12 +FLAG_VALS="$2"
13 +shift
14 +shift
15 +FLAG_MSGS="$@"
16 +
17 +# Use x in front of tested values as flags could be
18 +# interpreted by "test" to be for itself.
19 +if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE" 2>/dev/null)"
20 +then
21 + echo "$FLAG_MSGS"
22 + echo "$FLAG_VALS" >"$FLAG_FILE"
23 +fi