envvar-check 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- sh -*-
  2. # Check environment variables for sane values while testing.
  3. # Copyright (C) 2000-2018 Free Software Foundation, Inc.
  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 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  15. as_unset=unset
  16. else
  17. as_unset=false
  18. fi
  19. envvar_check_fail=0
  20. vars='
  21. _POSIX2_VERSION
  22. _STDBUF_E
  23. _STDBUF_I
  24. _STDBUF_O
  25. BASH_ENV
  26. BLOCKSIZE
  27. BLOCK_SIZE
  28. CDPATH
  29. COLUMNS
  30. DF_BLOCK_SIZE
  31. DU_BLOCK_SIZE
  32. ENV
  33. LANGUAGE
  34. LS_BLOCK_SIZE
  35. LS_COLORS
  36. OMP_NUM_THREADS
  37. POSIXLY_CORRECT
  38. QUOTING_STYLE
  39. SIMPLE_BACKUP_SUFFIX
  40. TABSIZE
  41. TERM
  42. COLORTERM
  43. TIME_STYLE
  44. TMPDIR
  45. VERSION_CONTROL
  46. '
  47. for var in $vars
  48. do
  49. $as_unset $var
  50. if eval test \"\${$var+set}\" = set; then
  51. echo "$0: the $var environment variable is set --" \
  52. ' unset it and rerun this test' >&2
  53. envvar_check_fail=1
  54. fi
  55. done
  56. test "$envvar_check_fail" = 1 && exit 1