From a2c41e650da5e303a5d27a587b5699fe9ea0db90 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 6 Apr 2015 17:52:28 +0200 Subject: [PATCH] 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 --- test/bin/checkflags | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 test/bin/checkflags diff --git a/test/bin/checkflags b/test/bin/checkflags new file mode 100755 index 000000000..a246a82c3 --- /dev/null +++ b/test/bin/checkflags @@ -0,0 +1,23 @@ +#!/bin/sh +# Author: Christian Couder +# MIT LICENSED + +if test "$#" -lt 3 +then + echo >&2 "usage $0 FILE VALUES MSG..." + exit 1 +fi + +FLAG_FILE="$1" +FLAG_VALS="$2" +shift +shift +FLAG_MSGS="$@" + +# Use x in front of tested values as flags could be +# interpreted by "test" to be for itself. +if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE" 2>/dev/null)" +then + echo "$FLAG_MSGS" + echo "$FLAG_VALS" >"$FLAG_FILE" +fi