summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-04-15 16:31:34 -0600
committerEric Blake <eblake@redhat.com>2015-04-21 06:15:35 -0600
commit76754e04fce5f6a7701bec57b057020585df2ae3 (patch)
treedc367be3756d07fa8f3b644bc6f8f7b50f5099e4 /configure.ac
parent7bc2c5623d2fed6421bf95279e5d610ed8dbaa50 (diff)
downloadautoconf-76754e04fce5f6a7701bec57b057020585df2ae3.tar.gz
lib: use shorter way to test if variable is set
Based on an idea by Bernhard Reutner-Fischer. We frequently used the idiom of 'test "${var+set}" = set' to test if $var was set to a non-empty string, but this can portably be trimmed to a more compact 'test ${var+y}' for a smaller configure file. Testing that a variable is not set can be done with '${var+false} :' (although the value of $? is not reliably 1 when the variable is set). The code for AS_VAR_TEST_SET already used the form '${var+:} false', but it is slightly longer, and does not guarantee $? of 1. Tested on coreutils, where the resulting configure file is about 1k smaller. * doc/autoconf.texi (Shell Substitutions): Prefer shorter sequence for testing if a variable is set. (Limitations of Builtins) <test (strings)>: Document it. * configure.ac: Use it. * lib/autoconf/c.m4 (_AC_PROG_CC_G, _AC_PROG_CXX_G) (_AC_PROG_OBJC_G, _AC_PROG_OBJCXX_G): Likewise. * lib/autoconf/fortran.m4 (_AC_PROG_FC_G): Likewise. * lib/autoconf/general.m4 (_AC_ENABLE_IF_ACTION, AC_CACHE_SAVE): Likewise. * lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_DEFAULT): Likewise. * lib/autoconf/programs.m4 (AC_PROG_INSTALL, AC_PROG_MKDIR_P) (_AC_PROG_LEX_YYTEXT_DECL): Likewise. * lib/autoconf/status.m4 (_AC_OUTPUT_MAIN_LOOP): Likewise. * lib/autotest/general.m4 (AT_INIT): Likewise. * tests/base.at (AC_CACHE_CHECK): Likewise. * tests/m4sh.at (LINENO): Likewise. * lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE) (_AS_DETECT_BETTER_SHELL, _AS_SHELL_SANITIZE) (_AS_PATH_SEPARATOR_PREPARE): Likewise. (AS_VAR_TEST_SET): Use shorter sequence. Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac6
1 files changed, 3 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 2709a0d1..e7029ebc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,9 +61,9 @@ AC_CACHE_CHECK([whether /bin/sh -n is known to work], [ac_cv_sh_n_works],
[if (
unset BASH_VERSION ZSH_VERSION
/bin/sh -c '
- test -n "${BASH_VERSION+set}" || # Bash
- test -n "${KSH_VERSION+set}" || # pdksh
- test -n "${ZSH_VERSION+set}" || # zsh
+ test ${BASH_VERSION+y} || # Bash
+ test ${KSH_VERSION+y} || # pdksh
+ test ${ZSH_VERSION+y} || # zsh
test -n "${.sh.version}" # ksh93; put this last since its syntax is dodgy
'
) 2>/dev/null