dollarvar.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # Copyright (C) 2009-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 to make sure that -Wportability complains about recursive
  17. # variable expansions and variables containing '$', '$(...)', or
  18. # '${...}' in the name. We support recursive variable expansions using
  19. # the latter two constructs for the 'silent-rules' option, and they are
  20. # rather widely supported in practice. OTOH variable definitions
  21. # containing a '$' on the left hand side of an assignment are not
  22. # portable in practice, even though POSIX allows them. :-/
  23. . test-init.sh
  24. cat >Makefile.am <<'EOF'
  25. x = 1
  26. foo$x = 1
  27. bar$(x) = 1
  28. baz${x} = 1
  29. bla = $(foo$x)
  30. bli = $(foo$(x))
  31. blo = $(foo${x})
  32. EOF
  33. $ACLOCAL
  34. AUTOMAKE_fails -Wportability
  35. grep 'Makefile.am:2' stderr
  36. grep 'Makefile.am:3' stderr
  37. grep 'Makefile.am:4' stderr
  38. grep 'Makefile.am:5' stderr
  39. grep 'Makefile.am:6' stderr
  40. grep 'Makefile.am:7' stderr
  41. AUTOMAKE_fails -Wportability -Wno-portability-recursive
  42. grep 'Makefile.am:2' stderr
  43. grep 'Makefile.am:3' stderr
  44. grep 'Makefile.am:4' stderr
  45. grep 'Makefile.am:5' stderr
  46. grep 'Makefile.am:6' stderr && exit 1
  47. grep 'Makefile.am:7' stderr && exit 1
  48. :