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