gdb: fix shellcheck warnings SC2086 (missing double quotes) in gdbarch.sh
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)
Fix all instances of:

    In gdbarch.sh line 31:
        if test ! -r ${file}
                     ^-----^ SC2086: Double quote to prevent globbing and word splitting.

    Did you mean:
        if test ! -r "${file}"

Note that some instances of these are in text that is eval'ed.  I'm
pretty sure that things could go wrong during the eval too, but that's
not something shellcheck can check.

gdb/ChangeLog:

* gdbarch.sh: Use double quotes around variables.

gdb/ChangeLog
gdb/gdbarch.sh

index b6928233fb8c2bbb7d1dc29b299981bc1e16107d..eefeac4c180dc19db56a01647bfb90ecdb4f20cb 100644 (file)
@@ -1,3 +1,7 @@
+2020-04-29  Simon Marchi  <simon.marchi@efficios.com>
+
+       * gdbarch.sh: Use double quotes around variables.
+
 2020-04-29  Simon Marchi  <simon.marchi@efficios.com>
 
        * gdbarch.sh: Use %s with printf, instead of variables in the
index 2780a819f915580efd42a455dffbe7d0c43470db..a934a7aa6bc1b3d08a9c408e45c5bf6fc347f342 100755 (executable)
@@ -28,10 +28,10 @@ LC_ALL=C ; export LC_ALL
 compare_new ()
 {
     file=$1
-    if test ! -r ${file}
+    if test ! -r "${file}"
     then
        echo "${file} missing? cp new-${file} ${file}" 1>&2
-    elif diff -u ${file} new-${file}
+    elif diff -u "${file}" "new-${file}"
     then
        echo "${file} unchanged" 1>&2
     else
@@ -70,7 +70,7 @@ ${line}"
            line="`echo "${line}" | sed -e 's/;;/; ;/g' -e 's/;;/; ;/g'`"
 
            OFS="${IFS}" ; IFS="[;]"
-           eval read ${read} <<EOF
+           eval read "${read}" <<EOF
 ${line}
 EOF
            IFS="${OFS}"
@@ -86,9 +86,9 @@ EOF
            # that ended up with just that space character.
            for r in ${read}
            do
-               if eval test \"\${${r}}\" = \"\ \"
+               if eval test "\"\${${r}}\" = ' '"
                then
-                   eval ${r}=""
+                   eval "${r}="
                fi
            done
 
@@ -1227,7 +1227,7 @@ ${class} ${returntype} ${function} ($formal)
 EOF
     for r in ${read}
     do
-       eval echo \"\ \ \ \ ${r}=\${${r}}\"
+       eval echo "\"    ${r}=\${${r}}\""
     done
     if class_is_predicate_p && fallback_default_p
     then
@@ -2162,7 +2162,7 @@ do
        printf "\n"
        printf "void\n"
        printf "set_gdbarch_%s (struct gdbarch *gdbarch,\n" "$function"
-        printf "            `echo ${function} | sed -e 's/./ /g'`  gdbarch_%s_ftype %s)\n" "$function" "$function"
+        printf "            `echo "$function" | sed -e 's/./ /g'`  gdbarch_%s_ftype %s)\n" "$function" "$function"
        printf "{\n"
        printf "  gdbarch->%s = %s;\n" "$function" "$function"
        printf "}\n"
@@ -2192,7 +2192,7 @@ do
        printf "\n"
        printf "void\n"
        printf "set_gdbarch_%s (struct gdbarch *gdbarch,\n" "$function"
-        printf "            `echo ${function} | sed -e 's/./ /g'`  %s %s)\n" "$returntype" "$function"
+        printf "            `echo "$function" | sed -e 's/./ /g'`  %s %s)\n" "$returntype" "$function"
        printf "{\n"
        printf "  gdbarch->%s = %s;\n" "$function" "$function"
        printf "}\n"