Merge branch 'branch-1.13.2' into maint
[platform/upstream/automake.git] / t / ax / is
1 #! /bin/sh
2 # Copyright (C) 2012-2013 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 # NOTE: keep this file Bourne-compatible, for the sake of systems with
25 #       non-POSIX /bin/sh (like Solaris).
26
27 set -e
28 set -u
29
30 # Initialize before unsetting, for shells (like older bash or Solaris
31 # ksh) that fail to unset variables that are already unset.
32 exp= got=; unset exp got
33 seen_eqeq=no
34 while test $# -gt 0; do
35   if test x"$1" = x"=="; then
36     if test $seen_eqeq = no; then
37       seen_eqeq=yes
38     else
39       echo "$0: more than one '==' argument seen on command line" >&2
40       exit 2
41     fi
42   else
43     if test $seen_eqeq = no; then
44       got=${got+"$got "}$1
45     else
46       exp=${exp+"$exp "}$1
47     fi
48   fi
49   shift
50 done
51
52 if test $seen_eqeq = no; then
53   echo "$0: no '==' argument seen on command line" >&2
54   exit 2
55 fi
56
57 test x"${exp-}" = x"${got-}"