xref: /netbsd-src/external/gpl3/autoconf/dist/tests/statesave.m4 (revision d874e91932377fc40d53f102e48fc3ee6f4fe9de)
1# statesave.m4 serial 2
2
3# Copyright (C) 2000-2012 Free Software Foundation, Inc.
4
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18# AC_STATE_SAVE(FILE)
19# -------------------
20# Save the shell variables and directory listing.  AT_CHECK_ENV uses these to
21# confirm that no test modifies variables outside the Autoconf namespace or
22# leaves temporary files.  AT_CONFIG_CMP uses the variable dumps to confirm
23# that tests have the same side effects regardless of caching.
24#
25# The sed script duplicates uniq functionality (thanks to 'info sed
26# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where
27# readdir can list a file multiple times in a rapidly changing
28# directory, while avoiding yet another fork.
29m4_defun([AC_STATE_SAVE],
30[(set) 2>&1 | sort >state-env.$1
31ls | sed '/^at-/d;/^state-/d;/^config\./d
32  h
33  :b
34  $b
35  N
36  /^\(.*\)\n\1$/ {
37    g
38    bb
39  }
40  $b
41  P
42  D' >state-ls.$1
43])# AC_STATE_SAVE
44