public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh
@ 2020-04-30  0:37 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2020-04-30  0:37 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=759cea5e3f7f141abfc2f31d5039cd7f109edf95

commit 759cea5e3f7f141abfc2f31d5039cd7f109edf95
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Wed Apr 29 20:35:34 2020 -0400

    gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh
    
    Fix all warnings of this type:
    
        In gdbarch.sh line 1238:
            if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
                                        ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
    
    See the rationale here [1].
    
    [1] https://github.com/koalaman/shellcheck/wiki/SC2166
    
    gdb/ChangeLog:
    
            * gdbarch.sh: Use shell operators && and || instead of
            -a and -o.

Diff:
---
 gdb/ChangeLog  |  5 +++++
 gdb/gdbarch.sh | 14 +++++++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d751c052ce9..bf0fdf55a5c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-29  Simon Marchi  <simon.marchi@efficios.com>
+
+	* gdbarch.sh: Use shell operators && and || instead of
+	-a and -o.
+
 2020-04-29  Simon Marchi  <simon.marchi@efficios.com>
 
 	* gdbarch.sh: Use $(...) instead of `...`.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 0e89bd1900b..f1b9276775e 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -156,8 +156,8 @@ EOF
 
 fallback_default_p ()
 {
-    [ -n "${postdefault}" -a "x${invalid_p}" != "x0" ] \
-	|| [ -n "${predefault}" -a "x${invalid_p}" = "x0" ]
+    ( [ -n "${postdefault}" ] && [ "x${invalid_p}" != "x0" ] ) \
+	|| ( [ -n "${predefault}" ] && [ "x${invalid_p}" = "x0" ] )
 }
 
 class_is_variable_p ()
@@ -1235,7 +1235,7 @@ EOF
 	kill $$
 	exit 1
     fi
-    if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
+    if [ "x${invalid_p}" = "x0" ] && [ -n "${postdefault}" ]
     then
 	echo "Error: postdefault is useless when invalid_p=0" 1>&2
 	kill $$
@@ -1921,7 +1921,7 @@ function_list | while do_read
 do
     if class_is_function_p || class_is_variable_p
     then
-	if [ -n "${predefault}" -a "x${predefault}" != "x0" ]
+	if [ -n "${predefault}" ] && [ "x${predefault}" != "x0" ]
 	then
 	  printf "  gdbarch->%s = %s;\n" "$function" "$predefault"
 	fi
@@ -2001,11 +2001,11 @@ do
 	then
 	    printf "  /* Skip verify of %s, has predicate.  */\n" "$function"
 	# FIXME: See do_read for potential simplification
- 	elif [ -n "${invalid_p}" -a -n "${postdefault}" ]
+	elif [ -n "${invalid_p}" ] && [ -n "${postdefault}" ]
 	then
 	    printf "  if (%s)\n" "$invalid_p"
 	    printf "    gdbarch->%s = %s;\n" "$function" "$postdefault"
-	elif [ -n "${predefault}" -a -n "${postdefault}" ]
+	elif [ -n "${predefault}" ] && [ -n "${postdefault}" ]
 	then
 	    printf "  if (gdbarch->%s == %s)\n" "$function" "$predefault"
 	    printf "    gdbarch->%s = %s;\n" "$function" "$postdefault"
@@ -2136,7 +2136,7 @@ do
 	fi
 	printf "  if (gdbarch_debug >= 2)\n"
 	printf "    fprintf_unfiltered (gdb_stdlog, \"gdbarch_%s called\\\\n\");\n" "$function"
-	if [ "x${actual}" = "x-" -o "x${actual}" = "x" ]
+	if [ "x${actual}" = "x-" ] || [ "x${actual}" = "x" ]
 	then
 	    if class_is_multiarch_p
 	    then


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-30  0:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30  0:37 [binutils-gdb] gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).