1.1 --- a/makesd-common Mon Jun 10 01:37:46 2019 +0200
1.2 +++ b/makesd-common Mon Jun 10 13:52:32 2019 +0200
1.3 @@ -75,12 +75,9 @@
1.4 if [ "$LINE" ] && [ "$1" ] ; then
1.5 FIELD=`echo "$LINE" | cut -d: -f1`
1.6
1.7 - for PROPERTY in $* ; do
1.8 - if [ "$PROPERTY" = "$FIELD" ] ; then
1.9 - echo "$LINE"
1.10 - break
1.11 - fi
1.12 - done
1.13 + if is_in "$FIELD" $* ; then
1.14 + echo "$LINE"
1.15 + fi
1.16
1.17 # Otherwise, select all properties.
1.18
1.19 @@ -115,6 +112,27 @@
1.20 echo "$1" | cut -d: -f2 | sed 's/^\s*//'
1.21 }
1.22
1.23 +# is_in <string> [ <member> ... ]
1.24 +#
1.25 +# Test whether the given string is present amongst the given members.
1.26 +
1.27 +is_in()
1.28 +{
1.29 + local STRING
1.30 +
1.31 + STRING=$1
1.32 +
1.33 + shift 1
1.34 +
1.35 + for MEMBER in $* ; do
1.36 + if [ "$STRING" = "$MEMBER" ] ; then
1.37 + return 0
1.38 + fi
1.39 + done
1.40 +
1.41 + return 1
1.42 +}
1.43 +
1.44 # search <string> <file>
1.45 #
1.46 # Search for the given string in the input, returning the line number.