color-tests: coloring can be forced on non-ANSI terminals as well
[platform/upstream/automake.git] / t / ax / is
1 #! /bin/sh
2 # Copyright (C) 2012 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test that two whitespace-separated lists are equal.
18 # Assumes the two lists are passed on the command line separated by
19 # a '==' string.
20 # This script is useful to test equality of lists in makefile rules,
21 # in the face of variables defined through line-continuations,
22 # automake rewrites and expansions of empty variables.
23
24 set -e
25 set -u
26
27 # Initialize before unsetting, for shells (like older bash or Solaris
28 # ksh) that fail to unset variables that are already unset.
29 exp= got=; unset exp got
30 seen_eqeq=no
31 while test $# -gt 0; do
32   if test x"$1" = x"=="; then
33     if test $seen_eqeq = no; then
34       seen_eqeq=yes
35     else
36       echo "$0: more than one '==' argument seen on command line" >&2
37       exit 2
38     fi
39   else
40     if test $seen_eqeq = no; then
41       got=${got+"$got "}$1
42     else
43       exp=${exp+"$exp "}$1
44     fi
45   fi
46   shift
47 done
48
49 if test $seen_eqeq = no; then
50   echo "$0: no '==' argument seen on command line" >&2
51   exit 2
52 fi
53
54 test x"${exp-}" = x"${got-}"