[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"'
From: |
Bernhard Reutner-Fischer |
Subject: |
[PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"' |
Date: |
Wed, 8 Apr 2015 22:01:01 +0200 |
test -n is faster to parse (let's say) and is already used in other
spots.
Tested with e.g. dash and busybox ash.
No regressions.
Please install.
2015-04-08 Bernhard Reutner-Fischer <address@hidden>
* lib/autoconf/general.m4 (_AC_ENABLE_IF_ACTION): Use
'test -n "${var+set}"' instead of 'test "${var+set}" = set.
(AC_CACHE_SAVE): Likewise.
* lib/autoconf/lang.m4 (ac_link_default): Likewise.
* lib/autoconf/programs.m4 (AC_PROG_INSTALL, AC_PROG_MKDIR_P): Likewise.
* lib/autoconf/status.m4 (_AC_OUTPUT_MAIN_LOOP): Likewise.
* lib/autotest/general.m4 (at_fn_create_debugging_script, Driver
loop.): Likewise.
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL,
_AS_SHELL_SANITIZE, _AS_PATH_SEPARATOR_PREPARE): Likewise.
* tests/base.at (AC_CACHE_CHECK): Likewise.
* tests/m4sh.at (LINENO stack): Likewise.
Signed-off-by: Bernhard Reutner-Fischer <address@hidden>
---
lib/autoconf/general.m4 | 4 ++--
lib/autoconf/lang.m4 | 2 +-
lib/autoconf/programs.m4 | 4 ++--
lib/autoconf/status.m4 | 8 ++++----
lib/autotest/general.m4 | 4 ++--
lib/m4sugar/m4sh.m4 | 6 +++---
tests/base.at | 2 +-
tests/m4sh.at | 2 +-
8 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 2d1a291..df06a7e 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1467,7 +1467,7 @@ _AC_ENABLE_IF_ACTION([$1], m4_translit([$2], [-+.],
[___]), [$3], [$4])
m4_define([_AC_ENABLE_IF_ACTION],
[m4_append_uniq([_AC_USER_OPTS], [$1_$2], [
])dnl
-AS_IF([test "${$1_$2+set}" = set], [$1val=$$1_$2; $3], [$4])dnl
+AS_IF([test -n "${$1_$2+set}"], [$1val=$$1_$2; $3], [$4])dnl
])
# AC_ARG_ENABLE(FEATURE, HELP-STRING, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
@@ -2044,7 +2044,7 @@ _AC_CACHE_DUMP() |
/^ac_cv_env_/b end
t clear
:clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ s/^\([^=]*\)=\(.*[{}].*\)$/test -n "${\1+set}" || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end'] >>confcache
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index 2e30f50..7f9e9f0 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -553,7 +553,7 @@ do
# certainly right.
break;;
*.* )
- if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ if test -n "${ac_cv_exeext+set}" && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
fi
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index 59df1a2..a0a7ef0 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -586,7 +586,7 @@ esac
])
rm -rf conftest.one conftest.two conftest.dir
])dnl
- if test "${ac_cv_path_install+set}" = set; then
+ if test -n "${ac_cv_path_install+set}"; then
INSTALL=$ac_cv_path_install
else
# As a last resort, use the slow shell script. Don't cache a
@@ -680,7 +680,7 @@ if test -z "$MKDIR_P"; then
done
done])])
test -d ./--version && rmdir ./--version
- if test "${ac_cv_path_mkdir+set}" = set; then
+ if test -n "${ac_cv_path_mkdir+set}"; then
MKDIR_P="$ac_cv_path_mkdir -p"
else
# As a last resort, use the slow shell script. Don't cache a
diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4
index ef9d521..3a2d271 100644
--- a/lib/autoconf/status.m4
+++ b/lib/autoconf/status.m4
@@ -1604,16 +1604,16 @@ AC_DEFUN([_AC_OUTPUT_MAIN_LOOP],
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
m4_ifdef([_AC_SEEN_CONFIG(FILES)],
-[ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+[ test -n "${CONFIG_FILES+set}" || CONFIG_FILES=$config_files
])dnl
m4_ifdef([_AC_SEEN_CONFIG(HEADERS)],
-[ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+[ test -n "${CONFIG_HEADERS+set}" || CONFIG_HEADERS=$config_headers
])dnl
m4_ifdef([_AC_SEEN_CONFIG(LINKS)],
-[ test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links
+[ test -n "${CONFIG_LINKS+set}" || CONFIG_LINKS=$config_links
])dnl
m4_ifdef([_AC_SEEN_CONFIG(COMMANDS)],
-[ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+[ test -n "${CONFIG_COMMANDS+set}" || CONFIG_COMMANDS=$config_commands
])dnl
fi
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index e70e326..44f57c3 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -363,7 +363,7 @@ at_fn_create_debugging_script ()
{
{
echo "#! /bin/sh" &&
- echo 'test "${ZSH_VERSION+set}" = set dnl
+ echo 'test -n "${ZSH_VERSION+set}" dnl
&& alias -g '\''${1+"address@hidden"}'\''='\''"address@hidden"'\''' &&
AS_ECHO(["cd '$at_dir'"]) &&
AS_ECHO(["exec \${CONFIG_SHELL-$SHELL} \"$at_myself\" -v -d ]dnl
@@ -1367,7 +1367,7 @@ dnl Unfortunately, ksh93 fork-bombs when we send TSTP, so
send STOP
dnl if this might be ksh (STOP prevents possible TSTP handlers inside
dnl AT_CHECKs from running). Then stop ourselves.
at_sig=TSTP
- test "${TMOUT+set}" = set && at_sig=STOP
+ test -n "${TMOUT+set}" && at_sig=STOP
kill -$at_sig $at_pids 2>/dev/null
fi
kill -STOP $$
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 603466f..fac49af 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -252,7 +252,7 @@ dnl Unfortunately, $as_me isn't available here.
AS_IF([test x$as_have_required = xno],
[AS_ECHO(["$[]0: This script requires a shell more modern than all"])
AS_ECHO(["$[]0: the shells that I found on your system."])
- if test x${ZSH_VERSION+set} = xset ; then
+ if test -n "${ZSH_VERSION+set}" ; then
AS_ECHO(["$[]0: In particular, zsh $ZSH_VERSION has bugs and should"])
AS_ECHO(["$[]0: be upgraded to zsh 4.3.4 or later."])
else
@@ -488,7 +488,7 @@ fi
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
+do eval test -n "\${$as_var+set}" \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
@@ -1272,7 +1272,7 @@ fi
# Compute the path separator.
m4_defun([_AS_PATH_SEPARATOR_PREPARE],
[# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
+if test -z "${PATH_SEPARATOR+set}"; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
diff --git a/tests/base.at b/tests/base.at
index 63bd36e..4058b22 100644
--- a/tests/base.at
+++ b/tests/base.at
@@ -342,7 +342,7 @@ my_cv_variable=true
AC_MSG_RESULT([$my_cv_variable])
# Ensure that the result is available at this point.
-if test ${my_cv_variable+set} != set; then
+if test -z "${my_cv_variable+set}"; then
AC_MSG_ERROR([AC@&@&address@hidden@_CACHE_VAL did not ensure that the cache
variable was set])
fi
diff --git a/tests/m4sh.at b/tests/m4sh.at
index df39ae7..34b13e1 100644
--- a/tests/m4sh.at
+++ b/tests/m4sh.at
@@ -297,7 +297,7 @@ test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth
2])
AS_LINENO_POP
test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
AS_LINENO_POP
-test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0])
+test -n "${as_lineno+set}" && AS_ERROR([as_lineno set at depth 0])
AS_EXIT([0])
]])
--
1.7.10.4
- [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"',
Bernhard Reutner-Fischer <=
- Re: [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"', Paul Eggert, 2015/04/08
- Re: [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"', Eric Blake, 2015/04/08
- Re: [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"', Eric Blake, 2015/04/08
- Re: [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"', Paul Eggert, 2015/04/09
- Re: [PATCH] Replace 'test "${var+set}" = set' with 'test -n "${var+set}"', Eric Blake, 2015/04/09
- [PATCH 2/4] AC_PROG_LEX: Rephrase LEX is set test, Bernhard Reutner-Fischer, 2015/04/09
- Re: [PATCH 2/4] AC_PROG_LEX: Rephrase LEX is set test, Eric Blake, 2015/04/09
- Re: [PATCH 2/4] AC_PROG_LEX: Rephrase LEX is set test, Bernhard Reutner-Fischer, 2015/04/09
- [PATCH 0/4] misc test(1) invocation tweaks, Bernhard Reutner-Fischer, 2015/04/09
- Re: [PATCH 0/4] misc test(1) invocation tweaks, Eric Blake, 2015/04/09