diff mbox

Consistently quote variables used with "test"

Message ID 20191218210608.211751-1-cbiesinger@google.com
State New
Headers show

Commit Message

Doug Evans via gdb-patches Dec. 18, 2019, 9:06 p.m. UTC
This ensures that empty variables and variables with spaces are handled
correctly.

Code was inconsistent on whether the constant string (e.g. yes/no)
should also be quoted; I tried to be consistent with surrounding code.

This fixes the error Eli reported during configure with mingw (though that
was not fatal).

gdb/ChangeLog:

2019-12-18  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Quote variable arguments of test.
	* gdbsupport/common.m4: Likewise.

gdb/gdbserver/ChangeLog:

2019-12-18  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Quote variable arguments of test.

Change-Id: I220e78b52c7db88b9dd058eda604635b03464fac
---
 gdb/configure              | 66 +++++++++++++++++++-------------------
 gdb/configure.ac           | 62 +++++++++++++++++------------------
 gdb/gdbserver/configure    |  8 ++---
 gdb/gdbserver/configure.ac |  4 +--
 gdb/gdbsupport/common.m4   |  4 +--
 5 files changed, 72 insertions(+), 72 deletions(-)

Comments

Eli Zaretskii Dec. 19, 2019, 3:30 a.m. UTC | #1
> Date: Wed, 18 Dec 2019 15:06:08 -0600
> From: "Christian Biesinger via gdb-patches" <gdb-patches@sourceware.org>
> Cc: Christian Biesinger <cbiesinger@google.com>
> 
> This ensures that empty variables and variables with spaces are handled
> correctly.
> 
> Code was inconsistent on whether the constant string (e.g. yes/no)
> should also be quoted; I tried to be consistent with surrounding code.
> 
> This fixes the error Eli reported during configure with mingw (though that
> was not fatal).

Thanks.
Tom Tromey Dec. 19, 2019, 7:24 p.m. UTC | #2
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> This ensures that empty variables and variables with spaces are handled
Christian> correctly.

Christian> Code was inconsistent on whether the constant string (e.g. yes/no)
Christian> should also be quoted; I tried to be consistent with surrounding code.

Christian> This fixes the error Eli reported during configure with mingw (though that
Christian> was not fatal).

Thanks.  This is ok.

Tom
Doug Evans via gdb-patches Dec. 19, 2019, 7:31 p.m. UTC | #3
On Thu, Dec 19, 2019 at 1:24 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> This ensures that empty variables and variables with spaces are handled
> Christian> correctly.
>
> Christian> Code was inconsistent on whether the constant string (e.g. yes/no)
> Christian> should also be quoted; I tried to be consistent with surrounding code.
>
> Christian> This fixes the error Eli reported during configure with mingw (though that
> Christian> was not fatal).
>
> Thanks.  This is ok.

Thanks, pushed.
To ssh://sourceware.org/git/binutils-gdb.git
   1ee7b812e7..0ad6b8ee70  HEAD -> master

Christian
Doug Evans via gdb-patches Dec. 26, 2019, 7:05 a.m. UTC | #4
On Thu, Dec 19, 2019 at 8:31 PM Christian Biesinger
<cbiesinger@google.com> wrote:
>
> On Thu, Dec 19, 2019 at 1:24 PM Tom Tromey <tom@tromey.com> wrote:
> >
> > >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
> >
> > Christian> This ensures that empty variables and variables with spaces are handled
> > Christian> correctly.
> >
> > Christian> Code was inconsistent on whether the constant string (e.g. yes/no)
> > Christian> should also be quoted; I tried to be consistent with surrounding code.
> >
> > Christian> This fixes the error Eli reported during configure with mingw (though that
> > Christian> was not fatal).
> >
> > Thanks.  This is ok.
>
> Thanks, pushed.
> To ssh://sourceware.org/git/binutils-gdb.git
>    1ee7b812e7..0ad6b8ee70  HEAD -> master

I just realized I only pushed this to trunk, whereas Eli reported this
issue on the gdb 9 branch. OK to push this to the branch as well?

Christian
Simon Marchi Dec. 26, 2019, 4:16 p.m. UTC | #5
On 2019-12-26 2:05 a.m., Christian Biesinger via gdb-patches wrote:
> I just realized I only pushed this to trunk, whereas Eli reported this
> issue on the gdb 9 branch. OK to push this to the branch as well?
> 
> Christian

Yes, please go ahead.

Simon
Doug Evans via gdb-patches Dec. 26, 2019, 10:35 p.m. UTC | #6
On Thu, Dec 26, 2019 at 5:16 PM Simon Marchi <simark@simark.ca> wrote:
>
> On 2019-12-26 2:05 a.m., Christian Biesinger via gdb-patches wrote:
> > I just realized I only pushed this to trunk, whereas Eli reported this
> > issue on the gdb 9 branch. OK to push this to the branch as well?
> >
> > Christian
>
> Yes, please go ahead.

Thanks, done.

To ssh://sourceware.org/git/binutils-gdb.git
   2030d2b12e..c0716f3e64  HEAD -> gdb-9-branch

Christian
diff mbox

Patch

diff --git a/gdb/configure b/gdb/configure
index 324eb50944..b572d414ca 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -6777,7 +6777,7 @@  else
 fi
 
 if test x"$enable_gdbmi" = xyes; then
-  if test -d $srcdir/mi; then
+  if test -d "$srcdir/mi"; then
     CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
     CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_MI_DEPS)"
     CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_MI_SRCS)"
@@ -6809,7 +6809,7 @@  if test "${enable_gdbtk+set}" = set; then :
       as_fn_error $? "bad value $enableval for --enable-gdbtk" "$LINENO" 5 ;;
   esac
 else
-  if test -d $srcdir/gdbtk; then
+  if test -d "$srcdir/gdbtk"; then
     enable_gdbtk=yes
   else
     enable_gdbtk=no
@@ -6956,7 +6956,7 @@  rm -f core conftest.err conftest.$ac_objext \
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var__etext" >&5
 $as_echo "$ac_cv_var__etext" >&6; }
-if test $ac_cv_var__etext = yes; then
+if test "$ac_cv_var__etext" = yes; then
 
 $as_echo "#define HAVE__ETEXT 1" >>confdefs.h
 
@@ -6989,13 +6989,13 @@  rm -f core conftest.err conftest.$ac_objext \
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_etext" >&5
 $as_echo "$ac_cv_var_etext" >&6; }
-if test $ac_cv_var_etext = yes; then
+if test "$ac_cv_var_etext" = yes; then
 
 $as_echo "#define HAVE_ETEXT 1" >>confdefs.h
 
 fi
 if test "$enable_profiling" = yes ; then
-  if test $ac_cv_func_monstartup = no || test $ac_cv_func__mcleanup = no; then
+  if test "$ac_cv_func_monstartup" = no || test "$ac_cv_func__mcleanup" = no; then
     as_fn_error $? "--enable-profiling requires monstartup and _mcleanup" "$LINENO" 5
   fi
   PROFILE_CFLAGS=-pg
@@ -7028,7 +7028,7 @@  fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cc_supports_pg" >&5
 $as_echo "$ac_cv_cc_supports_pg" >&6; }
 
-  if test $ac_cv_cc_supports_pg = no; then
+  if test "$ac_cv_cc_supports_pg" = no; then
     as_fn_error $? "--enable-profiling requires a compiler which supports -pg" "$LINENO" 5
   fi
 
@@ -8932,7 +8932,7 @@  fi
 # Check whether we should enable the TUI, but only do so if we really
 # can.
 if test x"$enable_tui" != xno; then
-  if test -d $srcdir/tui; then
+  if test -d "$srcdir/tui"; then
     if test "$curses_found" != no; then
       CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_TUI_OBS)"
       CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_TUI_DEPS)"
@@ -8955,7 +8955,7 @@  fi
 
 case $host_os in
   cygwin*)
-    if test -d $srcdir/libtermcap; then
+    if test -d "$srcdir/libtermcap"; then
       LIBS="../libtermcap/libtermcap.a $LIBS"
       ac_cv_search_tgetent="../libtermcap/libtermcap.a"
     fi ;;
@@ -10328,7 +10328,7 @@  $as_echo "$as_me: WARNING: python support disabled; some features may be unavail
 else
   case "${with_python}" in
   [\\/]* | ?:[\\/]*)
-    if test -d ${with_python}; then
+    if test -d "${with_python}"; then
       # Assume the python binary is ${with_python}/bin/python.
       python_prog="${with_python}/bin/python"
       python_prefix=
@@ -10364,7 +10364,7 @@  else
     python_prefix=
     case "${with_python}" in
     yes | auto)
-      if test ${build} = ${host}; then
+      if test "${build}" = "${host}"; then
         # Extract the first word of "python", so it can be a program name with args.
 set dummy python; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -14339,7 +14339,7 @@  done
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test $gdb_cv_cxx_std_thread = yes; then
+  if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
@@ -14378,7 +14378,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
 $as_echo "$gdb_cv_func_sigsetjmp" >&6; }
-if test $gdb_cv_func_sigsetjmp = yes; then
+if test "$gdb_cv_func_sigsetjmp" = "yes"; then
 
 $as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
 
@@ -14661,7 +14661,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_void" >&5
 $as_echo "$ac_cv_func_setpgrp_void" >&6; }
-if test $ac_cv_func_setpgrp_void = yes; then
+if test "$ac_cv_func_setpgrp_void" = yes; then
   $as_echo "#define SETPGRP_VOID 1" >>confdefs.h
 
 fi
@@ -14700,7 +14700,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_gnu_regex" >&5
 $as_echo "$gdb_cv_have_gnu_regex" >&6; }
-if test $gdb_cv_have_gnu_regex = yes; then
+if test "$gdb_cv_have_gnu_regex" = yes; then
   gdb_use_included_regex=no
 fi
 
@@ -14761,7 +14761,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_lwp" >&5
 $as_echo "$gdb_cv_struct_lwp" >&6; }
-if test $gdb_cv_struct_lwp = yes; then
+if test "$gdb_cv_struct_lwp" = yes; then
 
 $as_echo "#define HAVE_STRUCT_LWP 1" >>confdefs.h
 
@@ -14794,7 +14794,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_reg" >&5
 $as_echo "$gdb_cv_struct_reg" >&6; }
-if test $gdb_cv_struct_reg = yes; then
+if test "$gdb_cv_struct_reg" = yes; then
 
 $as_echo "#define HAVE_STRUCT_REG 1" >>confdefs.h
 
@@ -14880,7 +14880,7 @@  fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_ptrace_getregs" >&5
 $as_echo "$gdb_cv_have_ptrace_getregs" >&6; }
-if test $gdb_cv_have_ptrace_getregs = yes; then
+if test "$gdb_cv_have_ptrace_getregs" = yes; then
 
 $as_echo "#define HAVE_PTRACE_GETREGS 1" >>confdefs.h
 
@@ -14913,7 +14913,7 @@  fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_ptrace_getfpxregs" >&5
 $as_echo "$gdb_cv_have_ptrace_getfpxregs" >&6; }
-if test $gdb_cv_have_ptrace_getfpxregs = yes; then
+if test "$gdb_cv_have_ptrace_getfpxregs" = yes; then
 
 $as_echo "#define HAVE_PTRACE_GETFPXREGS 1" >>confdefs.h
 
@@ -14947,7 +14947,7 @@  fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_pt_getdbregs" >&5
 $as_echo "$gdb_cv_have_pt_getdbregs" >&6; }
-if test $gdb_cv_have_pt_getdbregs = yes; then
+if test "$gdb_cv_have_pt_getdbregs" = yes; then
 
 $as_echo "#define HAVE_PT_GETDBREGS 1" >>confdefs.h
 
@@ -14981,7 +14981,7 @@  fi
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_pt_getxmmregs" >&5
 $as_echo "$gdb_cv_have_pt_getxmmregs" >&6; }
-if test $gdb_cv_have_pt_getxmmregs = yes; then
+if test "$gdb_cv_have_pt_getxmmregs" = yes; then
 
 $as_echo "#define HAVE_PT_GETXMMREGS 1" >>confdefs.h
 
@@ -15343,7 +15343,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_c_long_long" >&5
 $as_echo "$gdb_cv_c_long_long" >&6; }
-if test $gdb_cv_c_long_long != yes; then
+if test "$gdb_cv_c_long_long" != yes; then
   # libdecnumber requires long long.
   as_fn_error $? "Compiler must support long long for GDB." "$LINENO" 5
 fi
@@ -15388,7 +15388,7 @@  fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_printf_has_long_long" >&5
 $as_echo "$gdb_cv_printf_has_long_long" >&6; }
-if test $gdb_cv_printf_has_long_long = yes; then
+if test "$gdb_cv_printf_has_long_long" = yes; then
 
 $as_echo "#define PRINTF_HAS_LONG_LONG 1" >>confdefs.h
 
@@ -15432,7 +15432,7 @@  fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_printf_has_decfloat" >&5
 $as_echo "$gdb_cv_printf_has_decfloat" >&6; }
-if test $gdb_cv_printf_has_decfloat = yes; then
+if test "$gdb_cv_printf_has_decfloat" = yes; then
 
 $as_echo "#define PRINTF_HAS_DECFLOAT 1" >>confdefs.h
 
@@ -15461,7 +15461,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_c_long_double" >&5
 $as_echo "$gdb_cv_c_long_double" >&6; }
-if test $gdb_cv_c_long_double = yes; then
+if test "$gdb_cv_c_long_double" = yes; then
 
 $as_echo "#define HAVE_LONG_DOUBLE 1" >>confdefs.h
 
@@ -15503,7 +15503,7 @@  fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_printf_has_long_double" >&5
 $as_echo "$gdb_cv_printf_has_long_double" >&6; }
-if test $gdb_cv_printf_has_long_double = yes; then
+if test "$gdb_cv_printf_has_long_double" = yes; then
 
 $as_echo "#define PRINTF_HAS_LONG_DOUBLE 1" >>confdefs.h
 
@@ -15545,7 +15545,7 @@  fi
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_scanf_has_long_double" >&5
 $as_echo "$gdb_cv_scanf_has_long_double" >&6; }
-if test $gdb_cv_scanf_has_long_double = yes; then
+if test "$gdb_cv_scanf_has_long_double" = yes; then
 
 $as_echo "#define SCANF_HAS_LONG_DOUBLE 1" >>confdefs.h
 
@@ -15682,7 +15682,7 @@  fi
 $as_echo "$found" >&6; }
 
 
-if test ${build} = ${host} -a ${host} = ${target} ; then
+if test "${build}" = "${host}" -a "${host}" = "${target}" ; then
    case ${host_os} in
    aix*)
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AiX thread debugging library" >&5
@@ -15713,7 +15713,7 @@  fi
 
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_have_aix_thread_debug" >&5
 $as_echo "$gdb_cv_have_aix_thread_debug" >&6; }
-      if test $gdb_cv_have_aix_thread_debug = yes; then
+      if test "$gdb_cv_have_aix_thread_debug" = yes; then
          CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
          CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
          LIBS="$LIBS -lpthdebug"
@@ -16346,7 +16346,7 @@  esac
 
 # libreadline needs libuser32.a in a cygwin environment
 WIN32LIBS=
-if test x$gdb_cv_os_cygwin = xyes; then
+if test x"$gdb_cv_os_cygwin" = xyes; then
     WIN32LIBS="-luser32"
     case "${target}" in
 	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
@@ -16410,7 +16410,7 @@  $as_echo "$gdb_cv_var_elf" >&6; }
   CFLAGS=$OLD_CFLAGS
   LDFLAGS=$OLD_LDFLAGS
   LIBS=$OLD_LIBS
-if test $gdb_cv_var_elf = yes; then
+if test "$gdb_cv_var_elf" = yes; then
   CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o dtrace-probe.o"
 
 $as_echo "#define HAVE_ELF 1" >>confdefs.h
@@ -16521,7 +16521,7 @@  $as_echo "$gdb_cv_var_macho" >&6; }
   CFLAGS=$OLD_CFLAGS
   LDFLAGS=$OLD_LDFLAGS
   LIBS=$OLD_LIBS
-if test $gdb_cv_var_macho = yes; then
+if test "$gdb_cv_var_macho" = yes; then
   CONFIG_OBS="$CONFIG_OBS machoread.o"
 fi
 
@@ -16529,7 +16529,7 @@  fi
 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
 
 # If building on ELF, look for lzma support for embedded compressed debug info.
-if test $gdb_cv_var_elf = yes; then
+if test "$gdb_cv_var_elf" = yes; then
 
 # Check whether --with-lzma was given.
 if test "${with_lzma+set}" = set; then :
@@ -17523,7 +17523,7 @@  $as_echo "${private_dir}" >&6; }
 	CONFIG_INSTALL="${CONFIG_INSTALL} install-gdbtk"
 	CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-gdbtk"
 
-	if test x$gdb_cv_os_cygwin = xyes; then
+	if test x"$gdb_cv_os_cygwin" = xyes; then
 	  WIN32LIBS="${WIN32LIBS} -lshell32 -lgdi32 -lcomdlg32 -ladvapi32"
 	  WIN32LDAPP="-Wl,--subsystem,console"
 	  CONFIG_OBS="${CONFIG_OBS} gdbres.o"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 6ba7c5cfa4..6ffd460b21 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -284,7 +284,7 @@  AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)]),
   esac],
   [enable_gdbmi=yes])
 if test x"$enable_gdbmi" = xyes; then
-  if test -d $srcdir/mi; then
+  if test -d "$srcdir/mi"; then
     CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
     CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_MI_DEPS)"
     CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_MI_SRCS)"
@@ -311,7 +311,7 @@  AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (GUI)]),
     *)
       AC_MSG_ERROR([bad value $enableval for --enable-gdbtk]) ;;
   esac],
-  [if test -d $srcdir/gdbtk; then
+  [if test -d "$srcdir/gdbtk"; then
     enable_gdbtk=yes
   else
     enable_gdbtk=no
@@ -389,7 +389,7 @@  AC_CACHE_CHECK([for _etext], ac_cv_var__etext,
 extern char _etext;
 ],
 [free (&_etext);], ac_cv_var__etext=yes, ac_cv_var__etext=no)])
-if test $ac_cv_var__etext = yes; then
+if test "$ac_cv_var__etext" = yes; then
   AC_DEFINE(HAVE__ETEXT, 1,
             [Define to 1 if your system has the _etext variable. ])
 fi
@@ -399,12 +399,12 @@  AC_CACHE_CHECK([for etext], ac_cv_var_etext,
 extern char etext;
 ],
 [free (&etext);], ac_cv_var_etext=yes, ac_cv_var_etext=no)])
-if test $ac_cv_var_etext = yes; then
+if test "$ac_cv_var_etext" = yes; then
   AC_DEFINE(HAVE_ETEXT, 1,
             [Define to 1 if your system has the etext variable. ])
 fi
 if test "$enable_profiling" = yes ; then
-  if test $ac_cv_func_monstartup = no || test $ac_cv_func__mcleanup = no; then
+  if test "$ac_cv_func_monstartup" = no || test "$ac_cv_func__mcleanup" = no; then
     AC_MSG_ERROR(--enable-profiling requires monstartup and _mcleanup)
   fi
   PROFILE_CFLAGS=-pg
@@ -415,7 +415,7 @@  if test "$enable_profiling" = yes ; then
     [AC_TRY_COMPILE([], [int x;], ac_cv_cc_supports_pg=yes,
      ac_cv_cc_supports_pg=no)])
 
-  if test $ac_cv_cc_supports_pg = no; then
+  if test "$ac_cv_cc_supports_pg" = no; then
     AC_MSG_ERROR(--enable-profiling requires a compiler which supports -pg)
   fi
 
@@ -534,7 +534,7 @@  fi
 # Check whether we should enable the TUI, but only do so if we really
 # can.
 if test x"$enable_tui" != xno; then
-  if test -d $srcdir/tui; then
+  if test -d "$srcdir/tui"; then
     if test "$curses_found" != no; then
       CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_TUI_OBS)"
       CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_TUI_DEPS)"
@@ -556,7 +556,7 @@  fi
 
 case $host_os in
   cygwin*)
-    if test -d $srcdir/libtermcap; then
+    if test -d "$srcdir/libtermcap"; then
       LIBS="../libtermcap/libtermcap.a $LIBS"
       ac_cv_search_tgetent="../libtermcap/libtermcap.a"
     fi ;;
@@ -758,7 +758,7 @@  if test "${with_python}" = no; then
 else
   case "${with_python}" in
   [[\\/]]* | ?:[[\\/]]*)
-    if test -d ${with_python}; then
+    if test -d "${with_python}"; then
       # Assume the python binary is ${with_python}/bin/python.
       python_prog="${with_python}/bin/python"
       python_prefix=
@@ -794,7 +794,7 @@  else
     python_prefix=
     case "${with_python}" in
     yes | auto)
-      if test ${build} = ${host}; then
+      if test "${build}" = "${host}"; then
         AC_PATH_PROG(python_prog_path, python, missing)
         if test "${python_prog_path}" = missing; then
           python_prog=missing
@@ -1335,7 +1335,7 @@  else
   else
     exit (1);
 ], ac_cv_func_setpgrp_void=no, ac_cv_func_setpgrp_void=yes)])
-if test $ac_cv_func_setpgrp_void = yes; then
+if test "$ac_cv_func_setpgrp_void" = yes; then
   AC_DEFINE(SETPGRP_VOID, 1)
 fi
 fi
@@ -1356,7 +1356,7 @@  AC_CACHE_CHECK(
 #endif],
     gdb_cv_have_gnu_regex=yes,
     gdb_cv_have_gnu_regex=no)])
-if test $gdb_cv_have_gnu_regex = yes; then
+if test "$gdb_cv_have_gnu_regex" = yes; then
   gdb_use_included_regex=no
 fi
 
@@ -1381,7 +1381,7 @@  AC_CACHE_CHECK([for struct lwp], gdb_cv_struct_lwp,
 #define _KMEMUSER
 #include <sys/lwp.h>], [struct lwp l;],
 gdb_cv_struct_lwp=yes, gdb_cv_struct_lwp=no)])
-if test $gdb_cv_struct_lwp = yes; then
+if test "$gdb_cv_struct_lwp" = yes; then
   AC_DEFINE(HAVE_STRUCT_LWP, 1,
             [Define to 1 if your system has struct lwp.])
 fi
@@ -1391,7 +1391,7 @@  AC_CACHE_CHECK([for struct reg in machine/reg.h], gdb_cv_struct_reg,
 [AC_TRY_COMPILE([#include <sys/types.h>
 #include <machine/reg.h>], [struct reg r;],
 gdb_cv_struct_reg=yes, gdb_cv_struct_reg=no)])
-if test $gdb_cv_struct_reg = yes; then
+if test "$gdb_cv_struct_reg" = yes; then
   AC_DEFINE(HAVE_STRUCT_REG, 1,
             [Define to 1 if your system has struct reg in <machine/reg.h>.])
 fi
@@ -1417,7 +1417,7 @@  AC_CACHE_VAL(gdb_cv_have_ptrace_getregs,
 		[gdb_cv_have_ptrace_getregs=yes],
 		[gdb_cv_have_ptrace_getregs=no])])
 AC_MSG_RESULT($gdb_cv_have_ptrace_getregs)
-if test $gdb_cv_have_ptrace_getregs = yes; then
+if test "$gdb_cv_have_ptrace_getregs" = yes; then
   AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
   [Define if sys/ptrace.h defines the PTRACE_GETREGS request.])
 fi
@@ -1430,7 +1430,7 @@  AC_CACHE_VAL(gdb_cv_have_ptrace_getfpxregs,
 		[gdb_cv_have_ptrace_getfpxregs=yes],
 		[gdb_cv_have_ptrace_getfpxregs=no])])
 AC_MSG_RESULT($gdb_cv_have_ptrace_getfpxregs)
-if test $gdb_cv_have_ptrace_getfpxregs = yes; then
+if test "$gdb_cv_have_ptrace_getfpxregs" = yes; then
   AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
   [Define if sys/ptrace.h defines the PTRACE_GETFPXREGS request.])
 fi
@@ -1444,7 +1444,7 @@  AC_CACHE_VAL(gdb_cv_have_pt_getdbregs,
 		[gdb_cv_have_pt_getdbregs=yes],
 		[gdb_cv_have_pt_getdbregs=no])])
 AC_MSG_RESULT($gdb_cv_have_pt_getdbregs)
-if test $gdb_cv_have_pt_getdbregs = yes; then
+if test "$gdb_cv_have_pt_getdbregs" = yes; then
   AC_DEFINE(HAVE_PT_GETDBREGS, 1,
   [Define if sys/ptrace.h defines the PT_GETDBREGS request.])
 fi
@@ -1458,7 +1458,7 @@  AC_CACHE_VAL(gdb_cv_have_pt_getxmmregs,
 		[gdb_cv_have_pt_getxmmregs=yes],
 		[gdb_cv_have_pt_getxmmregs=no])])
 AC_MSG_RESULT($gdb_cv_have_pt_getxmmregs)
-if test $gdb_cv_have_pt_getxmmregs = yes; then
+if test "$gdb_cv_have_pt_getxmmregs" = yes; then
   AC_DEFINE(HAVE_PT_GETXMMREGS, 1,
   [Define if sys/ptrace.h defines the PT_GETXMMREGS request.])
 fi
@@ -1494,7 +1494,7 @@  AC_CACHE_CHECK([for long long support in compiler], gdb_cv_c_long_long,
 [[switch (foo & 2) { case 0: return 1; }]])],
                                   gdb_cv_c_long_long=yes,
                                   gdb_cv_c_long_long=no)])
-if test $gdb_cv_c_long_long != yes; then
+if test "$gdb_cv_c_long_long" != yes; then
   # libdecnumber requires long long.
   AC_MSG_ERROR([Compiler must support long long for GDB.])
 fi
@@ -1515,7 +1515,7 @@  AC_CACHE_CHECK([for long long support in printf],
                               gdb_cv_printf_has_long_long=yes,
                               gdb_cv_printf_has_long_long=no,
                               gdb_cv_printf_has_long_long=no)])
-if test $gdb_cv_printf_has_long_long = yes; then
+if test "$gdb_cv_printf_has_long_long" = yes; then
   AC_DEFINE(PRINTF_HAS_LONG_LONG, 1,
             [Define to 1 if the "%ll" format works to print long longs.])
 fi
@@ -1534,7 +1534,7 @@  AC_CACHE_CHECK([for decfloat support in printf],
                               gdb_cv_printf_has_decfloat=yes,
                               gdb_cv_printf_has_decfloat=no,
                               gdb_cv_printf_has_decfloat=no)])
-if test $gdb_cv_printf_has_decfloat = yes; then
+if test "$gdb_cv_printf_has_decfloat" = yes; then
   AC_DEFINE(PRINTF_HAS_DECFLOAT, 1,
             [Define to 1 if the "%H, %D and %DD" formats work to print decfloats.])
 fi
@@ -1548,7 +1548,7 @@  AC_CACHE_CHECK([for long double support in compiler], gdb_cv_c_long_double,
                [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[long double foo;]])],
                                   gdb_cv_c_long_double=yes,
                                   gdb_cv_c_long_double=no)])
-if test $gdb_cv_c_long_double = yes; then
+if test "$gdb_cv_c_long_double" = yes; then
   AC_DEFINE(HAVE_LONG_DOUBLE, 1,
            [Define to 1 if the compiler supports long double.])
 fi
@@ -1565,7 +1565,7 @@  AC_CACHE_CHECK([for long double support in printf],
                               gdb_cv_printf_has_long_double=yes,
                               gdb_cv_printf_has_long_double=no,
                               gdb_cv_printf_has_long_double=no)])
-if test $gdb_cv_printf_has_long_double = yes; then
+if test "$gdb_cv_printf_has_long_double" = yes; then
   AC_DEFINE(PRINTF_HAS_LONG_DOUBLE, 1,
             [Define to 1 if the "%Lg" format works to print long doubles.])
 fi
@@ -1583,7 +1583,7 @@  AC_CACHE_CHECK([for long double support in scanf],
                               gdb_cv_scanf_has_long_double=yes,
                               gdb_cv_scanf_has_long_double=no,
                               gdb_cv_scanf_has_long_double=no)])
-if test $gdb_cv_scanf_has_long_double = yes; then
+if test "$gdb_cv_scanf_has_long_double" = yes; then
   AC_DEFINE(SCANF_HAS_LONG_DOUBLE, 1,
             [Define to 1 if the "%Lg" format works to scan long doubles.])
 fi
@@ -1666,7 +1666,7 @@  dnl
 dnl Note that we only want this if we are both native (host == target),
 dnl and not doing a canadian cross build (build == host).
 
-if test ${build} = ${host} -a ${host} = ${target} ; then
+if test "${build}" = "${host}" -a "${host}" = "${target}" ; then
    case ${host_os} in
    aix*)
       AC_MSG_CHECKING(for AiX thread debugging library)
@@ -1678,7 +1678,7 @@  if test ${build} = ${host} -a ${host} = ${target} ; then
                                    gdb_cv_have_aix_thread_debug=yes,
                                    gdb_cv_have_aix_thread_debug=no)])
       AC_MSG_RESULT($gdb_cv_have_aix_thread_debug)
-      if test $gdb_cv_have_aix_thread_debug = yes; then
+      if test "$gdb_cv_have_aix_thread_debug" = yes; then
          CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
          CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
          LIBS="$LIBS -lpthdebug"
@@ -1818,7 +1818,7 @@  AC_SUBST(SER_HARDWIRE)
 
 # libreadline needs libuser32.a in a cygwin environment
 WIN32LIBS=
-if test x$gdb_cv_os_cygwin = xyes; then
+if test x"$gdb_cv_os_cygwin" = xyes; then
     WIN32LIBS="-luser32"
     case "${target}" in
 	*cygwin*) WIN32LIBS="$WIN32LIBS -limagehlp"
@@ -1842,7 +1842,7 @@  AC_SUBST(WIN32LIBS)
 # Add ELF support to GDB, but only if BFD includes ELF support.
 GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_elf,
                  [bfd_get_elf_phdr_upper_bound (NULL)], elf-bfd.h)
-if test $gdb_cv_var_elf = yes; then
+if test "$gdb_cv_var_elf" = yes; then
   CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o dtrace-probe.o"
   AC_DEFINE(HAVE_ELF, 1,
 	    [Define if ELF support should be included.])
@@ -1855,7 +1855,7 @@  fi
 # Add macho support to GDB, but only if BFD includes it.
 GDB_AC_CHECK_BFD([for Mach-O support in BFD], gdb_cv_var_macho,
                  [bfd_mach_o_lookup_command (NULL, 0, NULL)], mach-o.h)
-if test $gdb_cv_var_macho = yes; then
+if test "$gdb_cv_var_macho" = yes; then
   CONFIG_OBS="$CONFIG_OBS machoread.o"
 fi
 
@@ -1863,7 +1863,7 @@  fi
 CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
 
 # If building on ELF, look for lzma support for embedded compressed debug info.
-if test $gdb_cv_var_elf = yes; then
+if test "$gdb_cv_var_elf" = yes; then
   AC_ARG_WITH(lzma,
     AS_HELP_STRING([--with-lzma], [support lzma compression (auto/yes/no)]),
     [], [with_lzma=auto])
@@ -1992,7 +1992,7 @@  if test "${enable_gdbtk}" = "yes"; then
 	CONFIG_INSTALL="${CONFIG_INSTALL} install-gdbtk"
 	CONFIG_UNINSTALL="${CONFIG_UNINSTALL} uninstall-gdbtk"
 
-	if test x$gdb_cv_os_cygwin = xyes; then
+	if test x"$gdb_cv_os_cygwin" = xyes; then
 	  WIN32LIBS="${WIN32LIBS} -lshell32 -lgdi32 -lcomdlg32 -ladvapi32"
 	  WIN32LDAPP="-Wl,--subsystem,console"
 	  CONFIG_OBS="${CONFIG_OBS} gdbres.o"
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index ccffde80ed..4de751b449 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -7731,7 +7731,7 @@  done
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test $gdb_cv_cxx_std_thread = yes; then
+  if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
@@ -7770,7 +7770,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_sigsetjmp" >&5
 $as_echo "$gdb_cv_func_sigsetjmp" >&6; }
-if test $gdb_cv_func_sigsetjmp = yes; then
+if test "$gdb_cv_func_sigsetjmp" = "yes"; then
 
 $as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
 
@@ -9198,7 +9198,7 @@  rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdbsrv_cv_have_td_version" >&5
 $as_echo "$gdbsrv_cv_have_td_version" >&6; }
-  if test $gdbsrv_cv_have_td_version = yes; then
+  if test "$gdbsrv_cv_have_td_version" = yes; then
 
 $as_echo "#define HAVE_TD_VERSION 1" >>confdefs.h
 
@@ -9263,7 +9263,7 @@  rm -f core conftest.err conftest.$ac_objext \
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdbsrv_cv_have_sync_builtins" >&5
 $as_echo "$gdbsrv_cv_have_sync_builtins" >&6; }
-if test $gdbsrv_cv_have_sync_builtins = yes; then
+if test "$gdbsrv_cv_have_sync_builtins" = yes; then
 
 $as_echo "#define HAVE_SYNC_BUILTINS 1" >>confdefs.h
 
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 4a6d88ebd1..c24ce82ac1 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -363,7 +363,7 @@  if test "$srv_linux_thread_db" = "yes"; then
   [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
 		  [gdbsrv_cv_have_td_version=yes],
 		  [gdbsrv_cv_have_td_version=no])])
-  if test $gdbsrv_cv_have_td_version = yes; then
+  if test "$gdbsrv_cv_have_td_version" = yes; then
     AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
   fi
 fi
@@ -398,7 +398,7 @@  AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
 		gdbsrv_cv_have_sync_builtins=yes,
 		gdbsrv_cv_have_sync_builtins=no)])
-if test $gdbsrv_cv_have_sync_builtins = yes; then
+if test "$gdbsrv_cv_have_sync_builtins" = yes; then
   AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
     [Define to 1 if the target supports __sync_*_compare_and_swap])
 fi
diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4
index c61753fb8e..d614a6edf8 100644
--- a/gdb/gdbsupport/common.m4
+++ b/gdb/gdbsupport/common.m4
@@ -62,7 +62,7 @@  AC_DEFUN([GDB_AC_COMMON], [
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test $gdb_cv_cxx_std_thread = yes; then
+  if test "$gdb_cv_cxx_std_thread" = "yes"; then
     AC_DEFINE(CXX_STD_THREAD, 1,
 	      [Define to 1 if std::thread works.])
   fi
@@ -75,7 +75,7 @@  AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp,
 #include <setjmp.h>
 ], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
 gdb_cv_func_sigsetjmp=yes, gdb_cv_func_sigsetjmp=no)])
-if test $gdb_cv_func_sigsetjmp = yes; then
+if test "$gdb_cv_func_sigsetjmp" = "yes"; then
   AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])
 fi
 ])