is 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #! /bin/sh
  2. # Copyright (C) 2012-2017 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. # Test that two whitespace-separated lists are equal.
  17. # Assumes the two lists are passed on the command line separated by
  18. # a '==' string.
  19. # This script is useful to test equality of lists in makefile rules,
  20. # in the face of variables defined through line-continuations,
  21. # automake rewrites and expansions of empty variables.
  22. # NOTE: keep this file Bourne-compatible, for the sake of systems with
  23. # non-POSIX /bin/sh (like Solaris).
  24. set -e
  25. set -u
  26. # Initialize before unsetting, for shells (like older bash or Solaris
  27. # ksh) that fail to unset variables that are already unset.
  28. exp= got=; unset exp got
  29. seen_eqeq=no
  30. while test $# -gt 0; do
  31. if test x"$1" = x"=="; then
  32. if test $seen_eqeq = no; then
  33. seen_eqeq=yes
  34. else
  35. echo "$0: more than one '==' argument seen on command line" >&2
  36. exit 2
  37. fi
  38. else
  39. if test $seen_eqeq = no; then
  40. got=${got+"$got "}$1
  41. else
  42. exp=${exp+"$exp "}$1
  43. fi
  44. fi
  45. shift
  46. done
  47. if test $seen_eqeq = no; then
  48. echo "$0: no '==' argument seen on command line" >&2
  49. exit 2
  50. fi
  51. test x"${exp-}" = x"${got-}"