Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC 0/3] [pre-commit] Add shfmt
@ 2026-09-02 13:17 Tom de Vries
  2026-09-02 13:17 ` [RFC 1/3] " Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-02 13:17 UTC (permalink / raw)
  To: gdb-patches

This series contains three patches.

The first adds an shfmt pre-commit hook.

The second enables it and uses it to format all shell scripts.

The third adds shfmt --simplify.

This is an RFC, given the large amount of changes that reformatting brings.

It would be nice to find a formatter closer to the current style.

Tom de Vries (3):
  [pre-commit] Add shfmt
  [pre-commit] Enable shfmt
  [gdb/contrib] Use shfmt --simplify in shfmt.sh

 .pre-commit-config.yaml                     |  10 ++
 gdb/contrib/cc-with-tweaks.sh               |  80 +++++----
 gdb/contrib/check-file-mode.sh              |  16 +-
 gdb/contrib/check-gnu-style-pre-commit.sh   |   5 +-
 gdb/contrib/gdb-add-index.sh                | 104 ++++++------
 gdb/contrib/pre-commit.py                   |   6 +-
 gdb/contrib/shellcheck.sh                   |   6 +-
 gdb/contrib/shfmt.sh                        |  84 +++++++++
 gdb/contrib/words.sh                        |  20 +--
 gdb/doc/makeinfo-wrapper.sh                 |  14 +-
 gdb/gcore-1.in                              | 141 +++++++--------
 gdb/gdb_buildall.sh                         | 123 ++++++--------
 gdb/gdb_mbuild.sh                           | 179 +++++++++-----------
 gdb/gstack-1.in                             |  25 +--
 gdb/make-init-c                             |   2 +-
 gdb/po/gdbtext                              |  23 +--
 gdb/syscalls/update-freebsd.sh              |  12 +-
 gdb/syscalls/update-linux-defaults.sh       |  29 ++--
 gdb/syscalls/update-linux-from-src.sh       |  25 ++-
 gdb/syscalls/update-linux.sh                |  26 +--
 gdb/syscalls/update-netbsd.sh               |  12 +-
 gdb/testsuite/lib/dg-add-core-file-count.sh |   6 +-
 gdb/testsuite/lib/notty-wrap                |   2 +-
 gdb/testsuite/make-check-all.sh             |  22 +--
 24 files changed, 524 insertions(+), 448 deletions(-)
 create mode 100755 gdb/contrib/shfmt.sh


base-commit: 192afd3ce7c2324cdbee2d4646df6cf1e9b6fd09
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC 1/3] [pre-commit] Add shfmt
  2026-09-02 13:17 [RFC 0/3] [pre-commit] Add shfmt Tom de Vries
@ 2026-09-02 13:17 ` Tom de Vries
  2026-09-02 13:17 ` [RFC 2/3] [pre-commit] Enable shfmt Tom de Vries
  2026-09-02 13:17 ` [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh Tom de Vries
  2 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-02 13:17 UTC (permalink / raw)
  To: gdb-patches

Add a new pre-commit hook shfmt, disabled.

A few notable changes in formatting compared to 'emacs' style are:
...
$ cat test.sh.bak
case "$1" in
    foo \
	| bar )
	:
	;;
esac

var=$(foo \
	  bar)
$ cp test.sh.bak test.sh; ./gdb/contrib/shfmt.sh test.sh
$ diff -u test.sh.bak test.sh
@@ -1,11 +1,11 @@
 case "$1" in
-    foo \
-	| bar )
+    foo | \
+	bar)
 	:
 	;;
 esac

 var=$(foo \
-	  bar)
+    bar)
...

The hook uses https://github.com/scop/pre-commit-shfmt.git, which provides a
.pre-commit-hooks.yaml file.  The file presents three alternatives:
- shfmt (prebuilt upstream executable)
- shfmt-src (build from source)
- shfmt-docker (Docker image)

I've chosen the shfmt-src one.  It relies on dependency
mvdan.cc/sh/v3/cmd/shfmt@v3.13.1, which points to go package
https://pkg.go.dev/mvdan.cc/sh/v3/cmd/shfmt, which uses repository
https://github.com/mvdan/sh.
---
 .pre-commit-config.yaml   | 12 ++++++
 gdb/contrib/pre-commit.py |  6 ++-
 gdb/contrib/shfmt.sh      | 83 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100755 gdb/contrib/shfmt.sh

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0b4285e6c82..2d2b5e38ca1 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -114,6 +114,18 @@ repos:
         # Enable strict mode to make sure we see and fix warnings.
         args: [--strict]
 
+  # Shell script hooks.
+  - repo: https://github.com/scop/pre-commit-shfmt.git
+    rev: v3.13.1-1
+    hooks:
+      - id: shfmt-src
+        alias: shfmt
+        entry: gdb/contrib/shfmt.sh
+        files: *gdb_files
+        args: []
+        # Disabled.
+        stages: [manual]
+
   # Local hooks.
   - repo: local
     hooks:
diff --git a/gdb/contrib/pre-commit.py b/gdb/contrib/pre-commit.py
index f3ad6f803b0..66b8667a2f2 100755
--- a/gdb/contrib/pre-commit.py
+++ b/gdb/contrib/pre-commit.py
@@ -49,7 +49,11 @@ def config_check_repo(repo):
 
     # Check version number.  Don't allow pre-releases like 9.0.0b1.
     # We currently only need to support x.y.z, but that could change.
-    if not re.fullmatch(r"\d+[.]\d+[.]\d+", rev):
+    re_rev = r"\d+[.]\d+[.]\d+"
+    if name == "https://github.com/scop/pre-commit-shfmt.git":
+        re_rev += r"-\d+"
+
+    if not re.fullmatch(re_rev, rev):
         print("Revision %s for repo %s not allowed." % (rev, name))
         return False
 
diff --git a/gdb/contrib/shfmt.sh b/gdb/contrib/shfmt.sh
new file mode 100755
index 00000000000..9cdf863b4d1
--- /dev/null
+++ b/gdb/contrib/shfmt.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+f2=()
+f4=()
+
+for f in "$@"; do
+    # The gdb/config/djgpp/* pattern matches the explicitly mentioned
+    # djcheck.sh and djconfig.sh.  Allow this.
+    # shellcheck disable=SC2221,SC2222
+    case "$f" in
+	*/configure)
+	    # Generated.
+	    continue
+	    ;;
+	gdb/config/djgpp/*)
+	    # For now, these scripts prefer `...` over $(...). See
+	    # gdb/config/djgpp/.shellcheckrc.
+	    # Shfmt automatically rewrites to $(...), so skip these.
+	    continue
+	    ;;
+	gdb/config/djgpp/djcheck.sh)
+	    # Mixed 2/4 indentation.
+	    continue
+	    ;;
+	gdb/config/djgpp/djconfig.sh \
+	    | gdb/contrib/expect-read1.sh \
+	    | gdb/features/feature_to_c.sh \
+	    | gdb/gdb_buildall.sh )
+	    f2=("${f2[@]}" "$f")
+	    ;;
+	*)
+	    f4=("${f4[@]}" "$f")
+	    ;;
+    esac
+done
+
+with_indent()
+{
+    indent="$1"
+    shift
+
+    if [ $# -eq 0 ]; then
+	return
+    fi
+
+    shfmt \
+	--language-dialect=auto \
+	--indent="$indent" \
+	--func-next-line \
+	--space-redirects \
+	--case-indent \
+	--binary-next-line \
+	--write \
+	"$@"
+}
+
+with_indent 2 "${f2[@]}"
+with_indent 4 "${f4[@]}"
+
+tmp=""
+
+cleanup()
+{
+    if [ "$tmp" != "" ]; then
+	rm -f "$tmp"
+    fi
+}
+
+# Schedule cleanup.
+trap cleanup EXIT
+
+tmp=$(mktemp)
+
+for f in "${f2[@]}" "${f4[@]}"; do
+    unexpand \
+	--first-only \
+	--tabs=8 \
+	"$f" \
+	> "$tmp"
+
+    # Use cat to preserve permissions on $f.
+    cat "$tmp" > "$f"
+done
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC 2/3] [pre-commit] Enable shfmt
  2026-09-02 13:17 [RFC 0/3] [pre-commit] Add shfmt Tom de Vries
  2026-09-02 13:17 ` [RFC 1/3] " Tom de Vries
@ 2026-09-02 13:17 ` Tom de Vries
  2026-09-02 13:17 ` [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh Tom de Vries
  2 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-02 13:17 UTC (permalink / raw)
  To: gdb-patches

The result of enabling the shfmt hook and running:
...
$ pre-commit run shfmt --all-files
...
and fixing:
...
gdb/gdb_buildall.sh:227:22: search and replace is a bash/mksh/zsh feature; \
  tried parsing as posix (parsed as posix via -ln=auto)
...
by using bash instead of sh in gdb/gdb_buildall.sh.
---
 .pre-commit-config.yaml                     |   2 -
 gdb/contrib/cc-with-tweaks.sh               |  80 +++++----
 gdb/contrib/check-file-mode.sh              |  16 +-
 gdb/contrib/check-gnu-style-pre-commit.sh   |   5 +-
 gdb/contrib/gdb-add-index.sh                | 104 ++++++------
 gdb/contrib/shellcheck.sh                   |   6 +-
 gdb/contrib/shfmt.sh                        |   8 +-
 gdb/contrib/words.sh                        |  20 +--
 gdb/doc/makeinfo-wrapper.sh                 |  14 +-
 gdb/gcore-1.in                              | 141 +++++++--------
 gdb/gdb_buildall.sh                         | 123 ++++++--------
 gdb/gdb_mbuild.sh                           | 179 +++++++++-----------
 gdb/gstack-1.in                             |  25 +--
 gdb/po/gdbtext                              |  23 +--
 gdb/syscalls/update-freebsd.sh              |  12 +-
 gdb/syscalls/update-linux-defaults.sh       |  29 ++--
 gdb/syscalls/update-linux-from-src.sh       |  25 ++-
 gdb/syscalls/update-linux.sh                |  26 +--
 gdb/syscalls/update-netbsd.sh               |  12 +-
 gdb/testsuite/lib/dg-add-core-file-count.sh |   6 +-
 gdb/testsuite/lib/notty-wrap                |   2 +-
 gdb/testsuite/make-check-all.sh             |  22 +--
 22 files changed, 428 insertions(+), 452 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2d2b5e38ca1..6f88c188c4e 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -123,8 +123,6 @@ repos:
         entry: gdb/contrib/shfmt.sh
         files: *gdb_files
         args: []
-        # Disabled.
-        stages: [manual]
 
   # Local hooks.
   - repo: local
diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index 047c748e165..215848c5eb7 100755
--- a/gdb/contrib/cc-with-tweaks.sh
+++ b/gdb/contrib/cc-with-tweaks.sh
@@ -53,16 +53,12 @@
 myname=cc-with-tweaks.sh
 mydir=$(dirname "$0")
 
-if [ -z "$GDB" ]
-then
-    if [ -f ./gdb ]
-    then
+if [ -z "$GDB" ]; then
+    if [ -f ./gdb ]; then
 	GDB="./gdb -data-directory data-directory"
-    elif [ -f ../gdb ]
-    then
+    elif [ -f ../gdb ]; then
 	GDB="../gdb -data-directory ../data-directory"
-    elif [ -f ../../gdb ]
-    then
+    elif [ -f ../../gdb ]; then
 	GDB="../../gdb -data-directory ../../data-directory"
     else
 	echo "$myname: unable to find usable gdb" >&2
@@ -100,10 +96,16 @@ while [ $# -gt 0 ]; do
 	-Z) want_objcopy_compress=true ;;
 	-z) want_dwz=true ;;
 	-i) want_index=true ;;
-	-n) want_index=true; index_options=-dwarf-5;;
+	-n)
+	    want_index=true
+	    index_options=-dwarf-5
+	    ;;
 	-c) want_index_cache=true ;;
 	-m) want_multi=true ;;
-	-5) want_multi=true; dwz_5flag=-5 ;;
+	-5)
+	    want_multi=true
+	    dwz_5flag=-5
+	    ;;
 	-p) want_dwp=true ;;
 	-l) want_gnu_debuglink=true ;;
 	*) break ;;
@@ -111,12 +113,9 @@ while [ $# -gt 0 ]; do
     shift
 done
 
-if [ "$want_index" = true ]
-then
-    if [ -z "$GDB_ADD_INDEX" ]
-    then
-	if [ -f "$mydir/gdb-add-index.sh" ]
-	then
+if [ "$want_index" = true ]; then
+    if [ -z "$GDB_ADD_INDEX" ]; then
+	if [ -f "$mydir/gdb-add-index.sh" ]; then
 	    GDB_ADD_INDEX="$mydir/gdb-add-index.sh"
 	else
 	    echo "$myname: unable to find usable contrib/gdb-add-index.sh" >&2
@@ -125,10 +124,8 @@ then
     fi
 fi
 
-for arg in "$@"
-do
-    if [ "$next_is_output_file" = "yes" ]
-    then
+for arg in "$@"; do
+    if [ "$next_is_output_file" = "yes" ]; then
 	output_file="$arg"
 	next_is_output_file=no
 	continue
@@ -146,14 +143,12 @@ do
     esac
 done
 
-if [ "$next_is_output_file" = "yes" ]
-then
+if [ "$next_is_output_file" = "yes" ]; then
     echo "$myname: Unable to find output file" >&2
     exit 1
 fi
 
-if [ "$have_link" = "no" ]
-then
+if [ "$have_link" = "no" ]; then
     "$@"
     exit $?
 fi
@@ -164,13 +159,12 @@ output_dir="${output_file%/*}"
 "$@"
 rc=$?
 [ $rc != 0 ] && exit $rc
-if [ ! -f "$output_file" ]
-then
+if [ ! -f "$output_file" ]; then
     echo "$myname: Internal error: $output_file missing." >&2
     exit 1
 fi
 
-get_tmpdir ()
+get_tmpdir()
 {
     subdir="$1"
     if [ "$subdir" = "" ]; then
@@ -217,9 +211,9 @@ fi
 
 if [ "$want_index_cache" = true ]; then
     $GDB -q -batch \
-	 -ex "set index-cache directory $INDEX_CACHE_DIR" \
-	 -ex "set index-cache enabled on" \
-	 -ex "file $output_file"
+	-ex "set index-cache directory $INDEX_CACHE_DIR" \
+	-ex "set index-cache enabled on" \
+	-ex "file $output_file"
     rc=$?
     [ $rc != 0 ] && exit $rc
 fi
@@ -233,8 +227,10 @@ if [ "$want_dwz" = true ] || [ "$want_multi" = true ]; then
     dwz_version_major=${dwz_version//\.*/}
     dwz_version_minor=${dwz_version//*\./}
     if [ "$dwz_version_major" -lt "$dwz_version_major_required" ] \
-	   || { [ "$dwz_version_major" -eq "$dwz_version_major_required" ] \
-		    && [ "$dwz_version_minor" -lt "$dwz_version_minor_required" ]; }; then
+	|| {
+	    [ "$dwz_version_major" -eq "$dwz_version_major_required" ] \
+		&& [ "$dwz_version_minor" -lt "$dwz_version_minor_required" ]
+	}; then
 	detected="$dwz_version_major.$dwz_version_minor"
 	required="$dwz_version_major_required.$dwz_version_minor_required"
 	echo "$myname: dwz version $detected detected, version $required or higher required"
@@ -284,14 +280,14 @@ fi
 
 if [ "$want_dwp" = true ]; then
     mapfile -t dwo_files \
-	    < \
-	    <($READELF -wi "${output_file}" \
-		  | grep _dwo_name \
-		  | sed -e 's/^.*: //' \
-		  | sort \
-		  | uniq)
+	< \
+	<($READELF -wi "${output_file}" \
+	    | grep _dwo_name \
+	    | sed -e 's/^.*: //' \
+	    | sort \
+	    | uniq)
     rc=0
-    if  [ ${#dwo_files[@]} -ne 0 ]; then
+    if [ ${#dwo_files[@]} -ne 0 ]; then
 	$DWP -o "${output_file}.dwp" "${dwo_files[@]}" > /dev/null
 	rc=$?
 	[ $rc != 0 ] && exit $rc
@@ -311,11 +307,11 @@ if [ "$want_gnu_debuglink" = true ]; then
 
     # Create stripped and debug versions of output_file.
     strip "${STRIP_ARGS_STRIP_DEBUG[@]}" "${output_file}" \
-	  -o "${stripped_file}"
+	-o "${stripped_file}"
     rc=$?
     [ $rc != 0 ] && exit $rc
     strip "${STRIP_ARGS_KEEP_DEBUG[@]}" "${output_file}" \
-	  -o "${debug_file}"
+	-o "${debug_file}"
     rc=$?
     [ $rc != 0 ] && exit $rc
 
@@ -329,7 +325,7 @@ if [ "$want_gnu_debuglink" = true ]; then
 	# Overwrite output_file with stripped version containing
 	# .gnu_debuglink to debug_file.
 	$OBJCOPY --add-gnu-debuglink="$link" "${stripped_file}" \
-		 "${output_file}"
+	    "${output_file}"
     )
     rc=$?
     [ $rc != 0 ] && exit $rc
diff --git a/gdb/contrib/check-file-mode.sh b/gdb/contrib/check-file-mode.sh
index 5a9b0e89fbe..4d611a08545 100755
--- a/gdb/contrib/check-file-mode.sh
+++ b/gdb/contrib/check-file-mode.sh
@@ -20,14 +20,14 @@ set -o pipefail
 no_exec_files=()
 for f in "$@"; do
     case $f in
-	*/*.py \
-	    | */*.sh \
-	    | */configure \
-	    | gdb/gstack-1.in \
-	    | gdb/gcore-1.in \
-	    | gdb/po/gdbtext \
-	    | gdb/make-init-c \
-	    | gdb/testsuite/lib/notty-wrap )
+	*/*.py | \
+	    */*.sh | \
+	    */configure | \
+	    gdb/gstack-1.in | \
+	    gdb/gcore-1.in | \
+	    gdb/po/gdbtext | \
+	    gdb/make-init-c | \
+	    gdb/testsuite/lib/notty-wrap)
 	    continue
 	    ;;
 	*)
diff --git a/gdb/contrib/check-gnu-style-pre-commit.sh b/gdb/contrib/check-gnu-style-pre-commit.sh
index f072e7b56ed..026cefa0296 100755
--- a/gdb/contrib/check-gnu-style-pre-commit.sh
+++ b/gdb/contrib/check-gnu-style-pre-commit.sh
@@ -16,7 +16,10 @@
 
 set -e
 
-scriptdir=$(cd "$(dirname "$0")" || exit 1; pwd -P)
+scriptdir=$(
+    cd "$(dirname "$0")" || exit 1
+    pwd -P
+)
 
 tmp=""
 
diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh
index 49f50a20e3e..e493fbd0eb5 100755
--- a/gdb/contrib/gdb-add-index.sh
+++ b/gdb/contrib/gdb-add-index.sh
@@ -27,16 +27,19 @@ VERSION="@VERSION@"
 
 myname="${0##*/}"
 
-print_usage() {
+print_usage()
+{
     prefix="Usage: $myname"
     echo "$prefix [-h|--help] [-v|--version] [--dwarf-5] FILENAME"
 }
 
-print_try_help() {
+print_try_help()
+{
     echo "Try '$myname --help' for more information."
 }
 
-print_help() {
+print_help()
+{
     print_usage
     echo
     echo "Add a .gdb_index section to FILENAME to facilitate faster debug"
@@ -48,7 +51,8 @@ print_help() {
     echo "                       instead of .gdb_index."
 }
 
-print_version() {
+print_version()
+{
     echo "GNU gdb-add-index (${PKGVERSION}) ${VERSION}"
 }
 
@@ -56,33 +60,33 @@ dwarf5=""
 
 # Parse options.
 until
-opt=$1
-case ${opt} in
-    --dwarf-5 | -dwarf-5)
-	dwarf5="-dwarf-5"
-	;;
-
-    --help | -help | -h)
-	print_help
-	exit 0
-	;;
-
-    --version | -version | -v)
-	print_version
-	exit 0
-	;;
-
-    -?*)
-	print_try_help 1>&2
-	exit 2
-	;;
-
-    *)
-	# No arguments remaining.
-	;;
-esac
-# Break from loop if the first character of OPT is not '-'.
-[ "x$(printf %.1s "$opt")" != "x-" ]
+    opt=$1
+    case ${opt} in
+	--dwarf-5 | -dwarf-5)
+	    dwarf5="-dwarf-5"
+	    ;;
+
+	--help | -help | -h)
+	    print_help
+	    exit 0
+	    ;;
+
+	--version | -version | -v)
+	    print_version
+	    exit 0
+	    ;;
+
+	-?*)
+	    print_try_help 1>&2
+	    exit 2
+	    ;;
+
+	*)
+	    # No arguments remaining.
+	    ;;
+    esac
+    # Break from loop if the first character of OPT is not '-'.
+    [ "x$(printf %.1s "$opt")" != "x-" ]
 do
     shift
 done
@@ -95,7 +99,7 @@ fi
 file="$1"
 
 if test -L "$file"; then
-    if ! command -v readlink >/dev/null 2>&1; then
+    if ! command -v readlink > /dev/null 2>&1; then
 	echo "$myname: 'readlink' missing.  Failed to follow symlink $1." 1>&2
 	exit 1
     fi
@@ -133,9 +137,9 @@ test "$dir" = "$file" && dir="."
 dwz_file=""
 if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then
     dwz_file=$($READELF --string-dump=.gnu_debugaltlink "$file" \
-		   | grep -A1  "'\.gnu_debugaltlink':" \
-		   | tail -n +2 \
-		   | sed 's/.*]//')
+	| grep -A1 "'\.gnu_debugaltlink':" \
+	| tail -n +2 \
+	| sed 's/.*]//')
     dwz_file=$(echo $dwz_file)
     if $READELF -S "$dwz_file" | grep -E -q " \.(gdb_index|debug_names) "; then
 	# Already has an index, skip it.
@@ -143,7 +147,7 @@ if $READELF -S "$file" | grep -q " \.gnu_debugaltlink "; then
     fi
 fi
 
-set_files ()
+set_files()
 {
     fpath="$1"
 
@@ -183,7 +187,7 @@ $GDB --batch -nx -iex 'set auto-load no' \
 # already stripped binary, it's a no-op.
 status=0
 
-handle_file ()
+handle_file()
 {
     fpath="$1"
 
@@ -202,35 +206,35 @@ handle_file ()
 	fi
 	if test -s "$debugstr"; then
 	    if ! $OBJCOPY --dump-section .debug_str="$debugstrmerge" "$fpath" \
-		 /dev/null 2> "$debugstrerr"; then
+		/dev/null 2> "$debugstrerr"; then
 		cat >&2 "$debugstrerr"
 		exit 1
 	    fi
-	    cat "$debugstr" >>"$debugstrmerge"
+	    cat "$debugstr" >> "$debugstrmerge"
 	    if grep -q "can't dump section '.debug_str' - it does not exist" \
-		    "$debugstrerr"; then
+		"$debugstrerr"; then
 		$OBJCOPY --add-section $section="$index" \
-			 --set-section-flags $section=readonly \
-			 --add-section .debug_str="$debugstrmerge" \
-		         --set-section-flags .debug_str=readonly \
-			 "$fpath" "$fpath"
+		    --set-section-flags $section=readonly \
+		    --add-section .debug_str="$debugstrmerge" \
+		    --set-section-flags .debug_str=readonly \
+		    "$fpath" "$fpath"
 	    else
 		$OBJCOPY --add-section $section="$index" \
-			 --set-section-flags $section=readonly \
-			 --update-section .debug_str="$debugstrmerge" \
-			 "$fpath" "$fpath"
+		    --set-section-flags $section=readonly \
+		    --update-section .debug_str="$debugstrmerge" \
+		    "$fpath" "$fpath"
 	    fi
 	else
 	    $OBJCOPY --add-section $section="$index" \
-		     --set-section-flags $section=readonly \
-		     "$fpath" "$fpath"
+		--set-section-flags $section=readonly \
+		"$fpath" "$fpath"
 	fi
 
 	status=$?
     else
 	echo "$myname: No index was created for $fpath" 1>&2
 	echo "$myname: [Was there no debuginfo? Was there already an index?]" \
-	     1>&2
+	    1>&2
     fi
 }
 
diff --git a/gdb/contrib/shellcheck.sh b/gdb/contrib/shellcheck.sh
index 6f5634ce38e..e7c92f317f4 100755
--- a/gdb/contrib/shellcheck.sh
+++ b/gdb/contrib/shellcheck.sh
@@ -41,9 +41,9 @@ for f in "$@"; do
 	    # Skip generated files.
 	    continue
 	    ;;
-	gdb/contrib/gdb-add-index.sh \
-	    | gdb/gdb_buildall.sh \
-	    | gdb/gdb_mbuild.sh )
+	gdb/contrib/gdb-add-index.sh | \
+	    gdb/gdb_buildall.sh | \
+	    gdb/gdb_mbuild.sh)
 	    # Skip unclean files.
 	    continue
 	    ;;
diff --git a/gdb/contrib/shfmt.sh b/gdb/contrib/shfmt.sh
index 9cdf863b4d1..0f1cf332b2a 100755
--- a/gdb/contrib/shfmt.sh
+++ b/gdb/contrib/shfmt.sh
@@ -22,10 +22,10 @@ for f in "$@"; do
 	    # Mixed 2/4 indentation.
 	    continue
 	    ;;
-	gdb/config/djgpp/djconfig.sh \
-	    | gdb/contrib/expect-read1.sh \
-	    | gdb/features/feature_to_c.sh \
-	    | gdb/gdb_buildall.sh )
+	gdb/config/djgpp/djconfig.sh | \
+	    gdb/contrib/expect-read1.sh | \
+	    gdb/features/feature_to_c.sh | \
+	    gdb/gdb_buildall.sh)
 	    f2=("${f2[@]}" "$f")
 	    ;;
 	*)
diff --git a/gdb/contrib/words.sh b/gdb/contrib/words.sh
index a96142a3232..f6ff6ff791d 100755
--- a/gdb/contrib/words.sh
+++ b/gdb/contrib/words.sh
@@ -56,7 +56,7 @@ while [ $# -gt 0 ]; do
 	    c=true
 	    shift
 	    ;;
-	--freq|-f)
+	--freq | -f)
 	    minfreq=$2
 	    maxfreq=$2
 	    shift 2
@@ -76,7 +76,7 @@ while [ $# -gt 0 ]; do
 	    shift 2
 	    ;;
 	*)
-	    break;
+	    break
 	    ;;
     esac
 done
@@ -89,7 +89,7 @@ fi
 awkfile=$(mktemp)
 trap 'rm -f "$awkfile"' EXIT
 
-cat > "$awkfile" <<EOF
+cat > "$awkfile" << EOF
 BEGIN {
     in_comment=0
 }
@@ -128,17 +128,17 @@ else
     cat "$@"
 fi \
     | sed \
-	  -e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
-	  -e 's/\[/\n/g' \
-	  -e 's/\]/\n/g' \
-	  -e "s/'/\n/g" \
-	  -e 's/[0-9][0-9]*/\n/g' \
-	  -e 's/[ \t]*//g' \
+	-e 's/[!"?;:%^$~#{}`&=@,. \t\/_()|<>\+\*-]/\n/g' \
+	-e 's/\[/\n/g' \
+	-e 's/\]/\n/g' \
+	-e "s/'/\n/g" \
+	-e 's/[0-9][0-9]*/\n/g' \
+	-e 's/[ \t]*//g' \
     | tr '[:upper:]' '[:lower:]' \
     | sort \
     | uniq -c \
     | awk "{ if (($minfreq == 0 || $minfreq <= \$1) \
-                 && ($maxfreq == 0 || \$1 <= $maxfreq)) { print \$0; } }" \
+		 && ($maxfreq == 0 || \$1 <= $maxfreq)) { print \$0; } }" \
     | awk '{ print length($0) " " $0; }' \
     | sort -n -r \
     | cut -d ' ' -f 2-
diff --git a/gdb/doc/makeinfo-wrapper.sh b/gdb/doc/makeinfo-wrapper.sh
index 7ad63bca3bc..752da77ed3f 100755
--- a/gdb/doc/makeinfo-wrapper.sh
+++ b/gdb/doc/makeinfo-wrapper.sh
@@ -23,11 +23,11 @@ prog="$3"
 shift 3
 
 major=$("$prog" --version \
-	    | grep "GNU texinfo" \
-	    | sed 's/^.* \([0-9][0-9]*\)\.[0-9][0-9]*\(.*\)\?$/\1/')
+    | grep "GNU texinfo" \
+    | sed 's/^.* \([0-9][0-9]*\)\.[0-9][0-9]*\(.*\)\?$/\1/')
 minor=$("$prog" --version \
-	    | grep "GNU texinfo" \
-	    | sed 's/^.* [0-9][0-9]*\.\([0-9][0-9]*\)\(.*\)\?$/\1/')
+    | grep "GNU texinfo" \
+    | sed 's/^.* [0-9][0-9]*\.\([0-9][0-9]*\)\(.*\)\?$/\1/')
 
 if [ "$major" = "" ] || [ "$major" = "" ]; then
     echo "Cannot determine makeinfo version for $prog.  Info documentation will not be build."
@@ -35,8 +35,10 @@ if [ "$major" = "" ] || [ "$major" = "" ]; then
 fi
 
 if [ "$major" -lt "$required_major" ] \
-       || { [ "$major" -eq "$required_major" ] \
-		&& [ "$minor" -lt "$required_minor" ]; }; then
+    || {
+	[ "$major" -eq "$required_major" ] \
+	    && [ "$minor" -lt "$required_minor" ]
+    }; then
     echo "$prog is too old, have $major.$minor, require $required_major.$required_minor.  Info documentation will not be build."
     exit
 fi
diff --git a/gdb/gcore-1.in b/gdb/gcore-1.in
index 2d3071d0ec5..a025e1c6690 100755
--- a/gdb/gcore-1.in
+++ b/gdb/gcore-1.in
@@ -36,7 +36,8 @@ data_directory=
 # The GDB binary to run.
 gdb_binary=
 
-print_usage() {
+print_usage()
+{
     prefix="Usage: $0"
     padding=$(printf '%*s' ${#prefix})
 
@@ -45,11 +46,13 @@ print_usage() {
     echo "$padding pid1 [pid2...pidN]"
 }
 
-print_try_help() {
+print_try_help()
+{
     echo "Try '$0 --help' for more information."
 }
 
-print_help() {
+print_help()
+{
     print_usage
     echo
     echo "Create a core file of a running program using GDB."
@@ -65,7 +68,8 @@ print_help() {
     echo "                       to GDB."
 }
 
-print_version() {
+print_version()
+{
     echo "GNU gcore (${PKGVERSION}) ${VERSION}"
 }
 
@@ -77,23 +81,23 @@ while getopts vhao:g:d:-: OPT; do
     fi
 
     case "$OPT" in
-        a)
-            case "$(uname -s)" in
-                Linux)
-                    use_coredump_filter="off"
-                    dump_excluded_mappings="on"
-                    ;;
-            esac
-            ;;
-        o)
-            prefix=$OPTARG
-            ;;
-        g)
-            gdb_binary="$OPTARG"
-            ;;
-        d)
-            data_directory="$OPTARG"
-            ;;
+	a)
+	    case "$(uname -s)" in
+		Linux)
+		    use_coredump_filter="off"
+		    dump_excluded_mappings="on"
+		    ;;
+	    esac
+	    ;;
+	o)
+	    prefix=$OPTARG
+	    ;;
+	g)
+	    gdb_binary="$OPTARG"
+	    ;;
+	d)
+	    data_directory="$OPTARG"
+	    ;;
 	h | help)
 	    print_help
 	    exit 0
@@ -107,21 +111,20 @@ while getopts vhao:g:d:-: OPT; do
 	    print_try_help 1>&2
 	    exit 2
 	    ;;
-        *)
+	*)
 	    # Unknown single character options are handled by the \?
 	    # case above.  This is formatted to match the error
 	    # getopts gives for an unknown single character option.
 	    echo "$0: illegal option -- $OPT" 1>&2
 	    print_try_help 1>&2
 	    exit 2
-            ;;
+	    ;;
     esac
 done
 
-shift $((OPTIND-1))
+shift $((OPTIND - 1))
 
-if [ "$#" -eq "0" ]
-then
+if [ "$#" -eq "0" ]; then
     print_usage 1>&2
     exit 1
 fi
@@ -130,31 +133,31 @@ fi
 # called.
 binary_path=$(dirname "$0")
 
-if test "$binary_path" = . ; then
-  # We got "." back as a path.  This means the user executed
-  # the gcore script locally (i.e. ./gcore) or called the
-  # script via a shell interpreter (i.e. sh gcore).
-  binary_basename=$(basename "$0")
-
-  # If the gcore script was called like "sh gcore" and the script
-  # lives in the current directory, "which" will not give us "gcore".
-  # So first we check if the script is in the current directory
-  # before using the output of "which".
-  if test -f "$binary_basename" ; then
-    # We have a local gcore script in ".".  This covers the case of
-    # doing "./gcore" or "sh gcore".
-    binary_path="."
-  else
-    # The gcore script was not found in ".", which means the script
-    # was called from somewhere else in $PATH by "sh gcore".
-    # Extract the correct path now.
-    binary_path_from_env=$(which "$0")
-    binary_path=$(dirname "$binary_path_from_env")
-  fi
+if test "$binary_path" = .; then
+    # We got "." back as a path.  This means the user executed
+    # the gcore script locally (i.e. ./gcore) or called the
+    # script via a shell interpreter (i.e. sh gcore).
+    binary_basename=$(basename "$0")
+
+    # If the gcore script was called like "sh gcore" and the script
+    # lives in the current directory, "which" will not give us "gcore".
+    # So first we check if the script is in the current directory
+    # before using the output of "which".
+    if test -f "$binary_basename"; then
+	# We have a local gcore script in ".".  This covers the case of
+	# doing "./gcore" or "sh gcore".
+	binary_path="."
+    else
+	# The gcore script was not found in ".", which means the script
+	# was called from somewhere else in $PATH by "sh gcore".
+	# Extract the correct path now.
+	binary_path_from_env=$(which "$0")
+	binary_path=$(dirname "$binary_path_from_env")
+    fi
 fi
 
 if [ -z "$gdb_binary" ]; then
-   gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@"
+    gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@"
 fi
 
 gdb_binary_basename=$(basename "$gdb_binary")
@@ -162,34 +165,32 @@ gdb_binary_basename=$(basename "$gdb_binary")
 # Check if the GDB binary is in the expected path.  If not, just
 # quit with a message.
 if [ ! -f "$gdb_binary" ]; then
-  echo "gcore: GDB binary ($gdb_binary) not found"
-  exit 1
+    echo "gcore: GDB binary ($gdb_binary) not found"
+    exit 1
 fi
 
 # Initialise return code.
 rc=0
 
 # Loop through pids
-for pid in "$@"
-do
-	# `</dev/null' to avoid touching interactive terminal if it is
-	# available but not accessible as GDB would get stopped on SIGTTIN.
-	"$gdb_binary" </dev/null \
-            ${data_directory:+--data-directory "$data_directory"} \
-	    --nx --batch --readnever -iex 'set debuginfod enabled off' \
-	    -ex "set pagination off" -ex "set height 0" -ex "set width 0" \
-            ${use_coredump_filter:+-ex "set use-coredump-filter ${use_coredump_filter}"} \
-	    ${dump_excluded_mappings:+-ex "set dump-excluded-mappings ${dump_excluded_mappings}"} \
-	    -ex "attach $pid" -ex "gcore $prefix.$pid" -ex detach -ex quit
-
-	if [ -r "$prefix.$pid" ] ; then
-	    rc=0
-	else
-	    echo "$gdb_binary_basename: failed to create $prefix.$pid"
-	    rc=1
-	    break
-	fi
-
+for pid in "$@"; do
+    # `</dev/null' to avoid touching interactive terminal if it is
+    # available but not accessible as GDB would get stopped on SIGTTIN.
+    "$gdb_binary" < /dev/null \
+	${data_directory:+--data-directory "$data_directory"} \
+	--nx --batch --readnever -iex 'set debuginfod enabled off' \
+	-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
+	${use_coredump_filter:+-ex "set use-coredump-filter ${use_coredump_filter}"} \
+	${dump_excluded_mappings:+-ex "set dump-excluded-mappings ${dump_excluded_mappings}"} \
+	-ex "attach $pid" -ex "gcore $prefix.$pid" -ex detach -ex quit
+
+    if [ -r "$prefix.$pid" ]; then
+	rc=0
+    else
+	echo "$gdb_binary_basename: failed to create $prefix.$pid"
+	rc=1
+	break
+    fi
 
 done
 
diff --git a/gdb/gdb_buildall.sh b/gdb/gdb_buildall.sh
index 1b82455ed0e..3f1185c8938 100644
--- a/gdb/gdb_buildall.sh
+++ b/gdb/gdb_buildall.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Build script to build GDB with all targets enabled.
 
@@ -22,14 +22,15 @@
 # Contributed by Markus Deuling <deuling@de.ibm.com>.
 # Based on gdb_mbuild.sh from Richard Earnshaw.
 
-
-LANG=c ; export LANG
-LC_ALL=c ; export LC_ALL
+LANG=c
+export LANG
+LC_ALL=c
+export LC_ALL
 
 # Prints a usage message.
 usage()
 {
-  cat <<EOF
+  cat << EOF
 Usage: gdb_buildall.sh [ <options> ... ] <srcdir> <builddir>
 
 Options:
@@ -56,49 +57,47 @@ force=false
 targexp=""
 bfd_flag=""
 clean=false
-while test $# -gt 0
-do
+while test $# -gt 0; do
   case "$1" in
-  -j )
+    -j)
       # Number of parallel make jobs.
       shift
       test $# -ge 1 || usage
       makejobs="-j $1"
       ;;
-      --clean )
-	# Shall the build directory be deleted after processing?
-	clean=true
-	;;
-    -e )
+    --clean)
+      # Shall the build directory be deleted after processing?
+      clean=true
+      ;;
+    -e)
       # A regular expression for selecting targets
       shift
       test $# -ge 1 || usage
       targexp="${targexp} -e ${1}"
       ;;
-    --force )
+    --force)
       # Force a rebuild
-      force=true ;
+      force=true
       ;;
     --bfd64)
       # Enable 64-bit BFD
       bfd_flag="--enable-64-bit-bfd"
       ;;
-    -* ) usage ;;
+    -*) usage ;;
     *) break ;;
   esac
   shift
 done
 
-if test $# -ne 2
-then
+if test $# -ne 2; then
   usage
 fi
 
 ### Environment.
 
 # Convert these to absolute directory paths.
-srcdir=`cd $1 && /bin/pwd` || exit 1
-builddir=`cd $2 && /bin/pwd` || exit 1
+srcdir=$(cd $1 && /bin/pwd) || exit 1
+builddir=$(cd $2 && /bin/pwd) || exit 1
 # Version of make to use
 make=${MAKE:-make}
 MAKE=${make}
@@ -108,33 +107,28 @@ ulimit -c 0
 
 # Just make sure we're in the right directory.
 maintainers=${srcdir}/gdb/MAINTAINERS
-if [ ! -r ${maintainers} ]
-then
-    echo Maintainers file ${maintainers} not found
-    exit 1
+if [ ! -r ${maintainers} ]; then
+  echo Maintainers file ${maintainers} not found
+  exit 1
 fi
 
-
 # Build GDB with all targets enabled.
 echo "Starting gdb_buildall.sh ..."
 
-trap "exit 1"  1 2 15
+trap "exit 1" 1 2 15
 dir=${builddir}/ALL
 
 # Should a scratch rebuild be forced, for perhaps the entire build be skipped?
-if ${force}
-then
+if ${force}; then
   echo ... forcing rebuild
   rm -rf ${dir}
 fi
 
 # Did the previous configure attempt fail?  If it did restart from scratch
-if test -d ${dir} -a ! -r ${dir}/Makefile
-then
+if test -d ${dir} -a ! -r ${dir}/Makefile; then
   echo ... removing partially configured
   rm -rf ${dir}
-  if test -d ${dir}
-  then
+  if test -d ${dir}; then
     echo "... ERROR: Unable to remove directory ${dir}"
     exit 1
   fi
@@ -145,17 +139,16 @@ mkdir -p ${dir}
 cd ${dir} || exit 1
 
 # Configure GDB.
-if test ! -r Makefile
-then
+if test ! -r Makefile; then
   # Default SIMOPTS to GDBOPTS.
   test -z "${simopts}" && simopts="${gdbopts}"
 
   # The config options.
   __build="--enable-targets=all"
-  __enable_gdb_build_warnings=`test -z "${gdbopts}" \
-    || echo "--enable-gdb-build-warnings=${gdbopts}"`
-  __enable_sim_build_warnings=`test -z "${simopts}" \
-    || echo "--enable-sim-build-warnings=${simopts}"`
+  __enable_gdb_build_warnings=$(test -z "${gdbopts}" \
+    || echo "--enable-gdb-build-warnings=${gdbopts}")
+  __enable_sim_build_warnings=$(test -z "${simopts}" \
+    || echo "--enable-sim-build-warnings=${simopts}")
   __configure="${srcdir}/configure \
     ${__build} ${bfd_flag}\
     ${__enable_gdb_build_warnings} \
@@ -163,11 +156,10 @@ then
   echo ... ${__configure}
   trap "echo Removing partially configured ${dir} directory ...; rm -rf ${dir}; exit 1" 1 2 15
   ${__configure} > Config.log 2>&1
-  trap "exit 1"  1 2 15
+  trap "exit 1" 1 2 15
 
   # Without Makefile GDB won't build.
-  if test ! -r Makefile
-  then
+  if test ! -r Makefile; then
     echo "... CONFIG ERROR: GDB couldn't be configured " | tee -a Config.log
     echo "... CONFIG ERROR: see Config.log for details "
     exit 1
@@ -176,49 +168,44 @@ fi
 
 # Build GDB, if not built.
 gdb_bin="gdb/gdb"
-if test ! -x gdb/gdb -a ! -x gdb/gdb.exe
-then
+if test ! -x gdb/gdb -a ! -x gdb/gdb.exe; then
   echo ... ${make} ${makejobs}
-  ( ${make} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
+  (
+    ${make} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
   ) > Build.log 2>&1
 
   # If the build fails, exit.
-  if test ! -x gdb/gdb -a ! -x gdb/gdb.exe
-  then
+  if test ! -x gdb/gdb -a ! -x gdb/gdb.exe; then
     echo "... BUILD ERROR: GDB couldn't be compiled " | tee -a Build.log
     echo "... BUILD ERROR: see Build.log for details "
     exit 1
   fi
-  if test -x gdb/gdb.exe
-  then
+  if test -x gdb/gdb.exe; then
     gdb_bin="gdb/gdb.exe"
   fi
 fi
 
-
 # Retrieve a list of settable architectures by invoking "set architecture"
 # without parameters.
-cat <<EOF > arch
+cat << EOF > arch
 set architecture
 quit
 EOF
 ./gdb/gdb --batch -nx -x arch 2>&1 | cat > gdb_archs
-tail -n 1 gdb_archs | sed 's/auto./\n/g' | sed 's/,/\n/g' |  sed 's/Requires an argument. Valid arguments are/\n/g' | sed '/^[ ]*$/d' > arch
+tail -n 1 gdb_archs | sed 's/auto./\n/g' | sed 's/,/\n/g' | sed 's/Requires an argument. Valid arguments are/\n/g' | sed '/^[ ]*$/d' > arch
 mv arch gdb_archs
 
-if test "${targexp}" != ""
-then
-  alltarg=`cat gdb_archs | grep ${targexp}`
+if test "${targexp}" != ""; then
+  alltarg=$(cat gdb_archs | grep ${targexp})
 else
-  alltarg=`cat gdb_archs`
+  alltarg=$(cat gdb_archs)
 fi
 rm -f gdb_archs
 
 # Test all architectures available in ALLTARG
 echo "maint print architecture for"
-echo "$alltarg" | while read target
-do
-  cat <<EOF > x
+echo "$alltarg" | while read target; do
+  cat << EOF > x
 set architecture ${target}
 maint print architecture
 quit
@@ -228,11 +215,9 @@ EOF
   echo -n "... ${target}"
   ./gdb/gdb -batch -nx -x x 2>&1 | cat > $log_file
   # Check GDBs results
-  if test ! -s $log_file
-  then
+  if test ! -s $log_file; then
     echo " ERR: gdb printed no output" | tee -a $log_file
-  elif test `grep -o internal-error $log_file | tail -n 1`
-  then
+  elif test $(grep -o internal-error $log_file | tail -n 1); then
     echo " ERR: gdb panic" | tee -a $log_file
   else
     echo " OK"
@@ -242,12 +227,11 @@ EOF
   rm -f mbuild.sed
   # Rules to replace <0xNNNN> with the corresponding function's name.
   sed -n -e '/<0x0*>/d' -e 's/^.*<0x\([0-9a-f]*\)>.*$/0x\1/p' $log_file \
-  | sort -u \
-  | while read addr
-  do
-    func="`addr2line -f -e ./$gdb_bin -s ${addr} | sed -n -e 1p`"
-    echo "s/<${addr}>/<${func}>/g"
-  done >> mbuild.sed
+    | sort -u \
+    | while read addr; do
+      func="$(addr2line -f -e ./$gdb_bin -s ${addr} | sed -n -e 1p)"
+      echo "s/<${addr}>/<${func}>/g"
+    done >> mbuild.sed
   # Rules to strip the leading paths off of file names.
   echo 's/"\/.*\/gdb\//"gdb\//g' >> mbuild.sed
   # Run the script.
@@ -259,8 +243,7 @@ done
 echo "done."
 
 # Clean up build directory if necessary.
-if ${clean}
-then
+if ${clean}; then
   echo "cleaning up $dir"
   rm -rf ${dir}
 fi
diff --git a/gdb/gdb_mbuild.sh b/gdb/gdb_mbuild.sh
index 44def191dc8..0f33bcd216e 100755
--- a/gdb/gdb_mbuild.sh
+++ b/gdb/gdb_mbuild.sh
@@ -22,12 +22,14 @@
 
 # Make certain that the script is not running in an internationalized
 # environment.
-LANG=c ; export LANG
-LC_ALL=c ; export LC_ALL
+LANG=c
+export LANG
+LC_ALL=c
+export LC_ALL
 
 usage()
 {
-    cat <<EOF
+    cat << EOF
 Usage: gdb_mbuild.sh [ <options> ... ] <srcdir> <builddir>
  Options:
    -j <makejobs>  Run <makejobs> in parallel.  Passed to make.
@@ -43,8 +45,8 @@ Usage: gdb_mbuild.sh [ <options> ... ] <srcdir> <builddir>
  Environment variables examined (with default if not defined):
    MAKE (make)"
 EOF
-    exit 1;
-cat <<NOTYET
+    exit 1
+    cat << NOTYET
   -b <maxbuilds> Run <maxbuild> builds in parallel.
 		 On a single cpu machine, 1 is recommended.
 NOTYET
@@ -59,63 +61,60 @@ force=false
 targexp=""
 verbose=0
 keep=false
-while test $# -gt 0
-do
+while test $# -gt 0; do
     case "$1" in
-    -j )
-	# Number of parallel make jobs.
-	shift
-	test $# -ge 1 || usage
-	makejobs="-j $1"
-	;;
-    -b | -c )
-	# Number of builds to fire off in parallel.
-	shift
-	test $# -ge 1 || usage
-	maxbuilds=$1
-	;;
-    -k )
-	# Should we soldier on after the first build fails?
-	keepgoing=-k
-	;;
-    --keep )
-	keep=true
-	;;
-    -e )
-	# A regular expression for selecting targets
-	shift
-	test $# -ge 1 || usage
-	targexp="${targexp} -e ${1}"
-	;;
-    -f )
-	# Force a rebuild
-	force=true ;
-	;;
-    -v )
-	# Be more, and more, and more, verbose
-	verbose=`expr ${verbose} + 1`
-	;;
-    -* ) usage ;;
-    *) break ;;
+	-j)
+	    # Number of parallel make jobs.
+	    shift
+	    test $# -ge 1 || usage
+	    makejobs="-j $1"
+	    ;;
+	-b | -c)
+	    # Number of builds to fire off in parallel.
+	    shift
+	    test $# -ge 1 || usage
+	    maxbuilds=$1
+	    ;;
+	-k)
+	    # Should we soldier on after the first build fails?
+	    keepgoing=-k
+	    ;;
+	--keep)
+	    keep=true
+	    ;;
+	-e)
+	    # A regular expression for selecting targets
+	    shift
+	    test $# -ge 1 || usage
+	    targexp="${targexp} -e ${1}"
+	    ;;
+	-f)
+	    # Force a rebuild
+	    force=true
+	    ;;
+	-v)
+	    # Be more, and more, and more, verbose
+	    verbose=$(expr ${verbose} + 1)
+	    ;;
+	-*) usage ;;
+	*) break ;;
     esac
     shift
 done
 
-
 ### COMMAND LINE PARAMETERS
 
-if test $# -ne 2
-then
+if test $# -ne 2; then
     usage
 fi
 
 # Convert these to absolute directory paths.
 
 # Where the sources live
-srcdir=`cd $1 && /bin/pwd` || exit 1
+srcdir=$(cd $1 && /bin/pwd) || exit 1
 
 # Where the builds occur
-builddir=`cd $2 && /bin/pwd` || exit 1
+builddir=$(cd $2 && /bin/pwd) || exit 1
 
 ### ENVIRONMENT PARAMETERS
 
@@ -124,17 +123,15 @@ make=${MAKE:-make}
 MAKE=${make}
 export MAKE
 
-
 # Where to look for the list of targets to test
 maintainers=${srcdir}/gdb/MAINTAINERS
-if [ ! -r ${maintainers} ]
-then
+if [ ! -r ${maintainers} ]; then
     echo Maintainers file ${maintainers} not found
     exit 1
 fi
 
 # Get the list of targets and the build options
-alltarg=`cat ${maintainers} | tr -s '[\t]' '[ ]' | sed -n '
+alltarg=$(cat ${maintainers} | tr -s '[\t]' '[ ]' | sed -n '
 /^[ ]*[-a-z0-9\.]*[ ]*[(]*--target=.*/ !d
 s/^.*--target=//
 s/).*$//
@@ -150,26 +147,23 @@ h
 b loop
 :end
 p
-' | if test "${targexp}" = ""
-then
+' | if test "${targexp}" = ""; then
     grep -v -e broken -e OBSOLETE
 else
     grep ${targexp}
-fi`
-
+fi)
 
 # Usage: fail <message> <test-that-should-succeed>.  Should the build
 # fail?  If the test is true, and we don't want to keep going, print
 # the message and shoot everything in sight and abort the build.
 
-fail ()
+fail()
 {
-    msg="$1" ; shift
-    if test "$@"
-    then
+    msg="$1"
+    shift
+    if test "$@"; then
 	echo "${target}: ${msg}"
-	if test "${keepgoing}" != ""
-	then
+	if test "${keepgoing}" != ""; then
 	    #exit 1
 	    return 1
 	else
@@ -179,45 +173,37 @@ fail ()
     fi
 }
 
-
 # Usage: log <level> <logfile>.  Write standard input to <logfile> and
 # stdout (if verbose >= level).
 
-log ()
+log()
 {
-    if test ${verbose} -ge $1
-    then
+    if test ${verbose} -ge $1; then
 	tee $2
     else
 	cat > $2
     fi
 }
 
-
-
 # Warn the user of what is coming, print the list of targets
 
 echo "$alltarg"
 echo ""
 
-
 # For each target, configure, build and test it.
 
-echo "$alltarg" | while read target gdbopts simopts
-do
+echo "$alltarg" | while read target gdbopts simopts; do
 
-    trap "exit 1"  1 2 15
+    trap "exit 1" 1 2 15
     dir=${builddir}/${target}
 
     # Should a scratch rebuild be forced, for perhaps the entire
     # build be skipped?
 
-    if ${force}
-    then
+    if ${force}; then
 	echo forcing ${target} ...
 	rm -rf ${dir}
-    elif test -f ${dir}
-    then
+    elif test -f ${dir}; then
 	echo "${target}"
 	continue
     else
@@ -227,12 +213,10 @@ do
     # Did the previous configure attempt fail?  If it did
     # restart from scratch.
 
-    if test -d ${dir} -a ! -r ${dir}/Makefile
-    then
+    if test -d ${dir} -a ! -r ${dir}/Makefile; then
 	echo ... removing partially configured ${target}
 	rm -rf ${dir}
-	if test -d ${dir}
-	then
+	if test -d ${dir}; then
 	    echo "${target}: unable to remove directory ${dir}"
 	    exit 1
 	fi
@@ -246,16 +230,15 @@ do
     # Configure, if not already.  Should this go back to being
     # separate and done in parallel?
 
-    if test ! -r Makefile
-    then
+    if test ! -r Makefile; then
 	# Default SIMOPTS to GDBOPTS.
 	test -z "${simopts}" && simopts="${gdbopts}"
 	# The config options
 	__target="--target=${target}"
-	__enable_gdb_build_warnings=`test -z "${gdbopts}" \
-	    || echo "--enable-gdb-build-warnings=${gdbopts}"`
-	__enable_sim_build_warnings=`test -z "${simopts}" \
-	    || echo "--enable-sim-build-warnings=${simopts}"`
+	__enable_gdb_build_warnings=$(test -z "${gdbopts}" \
+	    || echo "--enable-gdb-build-warnings=${gdbopts}")
+	__enable_sim_build_warnings=$(test -z "${simopts}" \
+	    || echo "--enable-sim-build-warnings=${simopts}")
 	__configure="${srcdir}/configure \
 	    ${__target} \
 	    ${__enable_gdb_build_warnings} \
@@ -263,20 +246,20 @@ do
 	echo ... ${__configure}
 	trap "echo Removing partially configured ${dir} directory ...; rm -rf ${dir}; exit 1" 1 2 15
 	${__configure} 2>&1 | log 2 Config.log
-	trap "exit 1"  1 2 15
+	trap "exit 1" 1 2 15
     fi
     fail "configure failed" ! -r Makefile
 
     # Build, if not built.
 
-    if test ! -x gdb/gdb -a ! -x gdb/gdb.exe
-    then
+    if test ! -x gdb/gdb -a ! -x gdb/gdb.exe; then
 	# Iff the build fails remove the final build target so that
 	# the follow-on code knows things failed.  Stops the follow-on
 	# code thinking that a failed rebuild succeeded (executable
 	# left around from previous build).
 	echo ... ${make} ${keepgoing} ${makejobs} ${target}
-	( ${make} ${keepgoing} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
+	(
+	    ${make} ${keepgoing} ${makejobs} all-gdb || rm -f gdb/gdb gdb/gdb.exe
 	) 2>&1 | log 1 Build.log
     fi
     fail "compile failed" ! -x gdb/gdb -a ! -x gdb/gdb.exe
@@ -285,7 +268,7 @@ do
 
     echo ... run ${target}
     rm -f core gdb.core ${dir}/gdb/x
-    cat <<EOF > x
+    cat << EOF > x
 maint print architecture
 quit
 EOF
@@ -302,13 +285,12 @@ EOF
     # Rules to replace <0xNNNN> with the corresponding function's
     # name.
     sed -n -e '/<0x0*>/d' -e 's/^.*<0x\([0-9a-f]*\)>.*$/0x\1/p' Gdb.log \
-    | sort -u \
-    | while read addr
-    do
-	func="`addr2line -f -e ./gdb/gdb -s ${addr} | sed -n -e 1p`"
-	test ${verbose} -gt 0 && echo "${addr} ${func}" 1>&2
-	echo "s/<${addr}>/<${func}>/g"
-    done >> mbuild.sed
+	| sort -u \
+	| while read addr; do
+	    func="$(addr2line -f -e ./gdb/gdb -s ${addr} | sed -n -e 1p)"
+	    test ${verbose} -gt 0 && echo "${addr} ${func}" 1>&2
+	    echo "s/<${addr}>/<${func}>/g"
+	done >> mbuild.sed
     # Rules to strip the leading paths off of file names.
     echo 's/"\/.*\/gdb\//"gdb\//g' >> mbuild.sed
     # Run the script
@@ -319,8 +301,7 @@ EOF
 
     cd ${builddir}
 
-    if ${keep}
-    then
+    if ${keep}; then
 	:
     else
 	rm -f ${target}.tmp
diff --git a/gdb/gstack-1.in b/gdb/gstack-1.in
index 9079e70a746..eb631a36a77 100755
--- a/gdb/gstack-1.in
+++ b/gdb/gstack-1.in
@@ -40,15 +40,18 @@ if [ ! -x "$AWK" ]; then
     exit 2
 fi
 
-function print_usage() {
+function print_usage()
+{
     echo "Usage: $0 [-h|--help] [-v|--version] PID"
 }
 
-function print_try_help() {
+function print_try_help()
+{
     echo "Try '$0 --help' for more information."
 }
 
-function print_help() {
+function print_help()
+{
     print_usage
     echo "Print a stack trace of a running program"
     echo
@@ -56,7 +59,8 @@ function print_help() {
     echo "  -v, --version      Print version information then exit."
 }
 
-function print_version() {
+function print_version()
+{
     echo "GNU gstack (${PKGVERSION}) ${VERSION}"
 }
 
@@ -80,7 +84,8 @@ while getopts hv-: OPT; do
 	\?)
 	    # getopts has already output an error message.
 	    print_try_help 1>&2
-	    exit 2 ;;
+	    exit 2
+	    ;;
 	*)
 	    echo "$0: unrecognized option '--$OPT'" 1>&2
 	    print_try_help 1>&2
@@ -88,7 +93,7 @@ while getopts hv-: OPT; do
 	    ;;
     esac
 done
-shift $((OPTIND-1))
+shift $((OPTIND - 1))
 
 # The sole remaining argument should be the PID of the process
 # whose backtrace is desired.
@@ -99,7 +104,8 @@ fi
 
 PID=$1
 
-awk_script=$(cat << EOF
+awk_script=$(
+    cat << EOF
 BEGIN {
   first=1
   attach_okay=0
@@ -129,11 +135,11 @@ if (attach_okay == 0)
   exit 2
 }
 EOF
-	  )
+)
 
 # Run GDB and remove some unwanted noise.
 # shellcheck disable=SC2086
-"$GDB" --quiet -nx $GDBARGS <<EOF |
+"$GDB" --quiet -nx $GDBARGS << EOF | $AWK -- "$awk_script"
 set width 0
 set height 0
 set pagination no
@@ -145,4 +151,3 @@ thread apply all bt
 end
 attach-bt $PID
 EOF
-$AWK -- "$awk_script"
diff --git a/gdb/po/gdbtext b/gdb/po/gdbtext
index 152a0dba0c4..20c49e578cd 100755
--- a/gdb/po/gdbtext
+++ b/gdb/po/gdbtext
@@ -1,30 +1,31 @@
 #!/bin/sh -e
 
-if test $# -lt 3
-then
+if test $# -lt 3; then
     echo "Usage: $0 <xgettext> <package>  <directory> ..." 1>&2
     exit 0
 fi
 
-xgettext=$1 ; shift
-package=$1 ; shift
+xgettext=$1
+shift
+package=$1
+shift
 
-find_files ()
+find_files()
 {
     for d in "$@"; do
 	(
 	    cd "$d"
 	    find -- * \
-		 -name '*-stub.c' -prune -o \
-		 -name 'testsuite' -prune -o \
-		 -name 'init.c' -prune -o \
-		 -name '*.[hc]' -print -o \
-		 -name '*.cc' -print
+		-name '*-stub.c' -prune -o \
+		-name 'testsuite' -prune -o \
+		-name 'init.c' -prune -o \
+		-name '*.[hc]' -print -o \
+		-name '*.cc' -print
 	)
     done
 }
 
-run_xgettext ()
+run_xgettext()
 {
     # Transform:
     #   "$@" == "arg1" "arg2" ...
diff --git a/gdb/syscalls/update-freebsd.sh b/gdb/syscalls/update-freebsd.sh
index e91817cf9f3..7b6c38e045c 100755
--- a/gdb/syscalls/update-freebsd.sh
+++ b/gdb/syscalls/update-freebsd.sh
@@ -28,14 +28,14 @@
 # rather than syscalls.master as syscall.h is easier to parse.
 
 if [ $# -ne 1 ]; then
-   echo "Error: Path to syscall.h missing. Aborting."
-   echo "Usage: update-freebsd.sh <path-to-syscall.h>"
-   exit 1
+    echo "Error: Path to syscall.h missing. Aborting."
+    echo "Usage: update-freebsd.sh <path-to-syscall.h>"
+    exit 1
 fi
 
 year=$(date +%Y)
 
-cat > freebsd.xml.tmp <<EOF
+cat > freebsd.xml.tmp << EOF
 <?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*-  -->
 <!-- vi:set ro: -->
 <!-- Copyright (C) 2009-$year Free Software Foundation, Inc.
@@ -63,7 +63,7 @@ awk '
     sub(/^SYS_/,"",$2);
     printf "  <syscall name=\"%s\" number=\"%s\"", $2, $3
     if (sub(/^freebsd[0-9]*_/,"",$2) != 0)
-        printf " alias=\"%s\"", $2
+	printf " alias=\"%s\"", $2
     printf "/>\n"
 }
 /\/\* [0-9]* is obsolete [a-z_]* \*\// {
@@ -73,7 +73,7 @@ awk '
     printf "  <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5
 }' "$1" >> freebsd.xml.tmp
 
-cat >> freebsd.xml.tmp <<EOF
+cat >> freebsd.xml.tmp << EOF
 </syscalls_info>
 EOF
 
diff --git a/gdb/syscalls/update-linux-defaults.sh b/gdb/syscalls/update-linux-defaults.sh
index ae8288ff528..b39fe309715 100755
--- a/gdb/syscalls/update-linux-defaults.sh
+++ b/gdb/syscalls/update-linux-defaults.sh
@@ -33,11 +33,11 @@ if [ ! -d "$d" ]; then
     exit 1
 fi
 
-pre ()
+pre()
 {
     year=$(date +%Y)
 
-    cat <<EOF
+    cat << EOF
 <?xml version="1.0"?>
 <!-- Copyright (C) 2009-$year Free Software Foundation, Inc.
 
@@ -51,33 +51,32 @@ EOF
     echo '<syscalls_defaults>'
 }
 
-
-post ()
+post()
 {
     echo '</syscalls_defaults>'
 }
 
-generate ()
+generate()
 {
     pre
 
     grep -rn -E "T[A-Z][,|]" "$d/src/linux/" \
 	| sed -e 's/\(T[A-Z][,|].*\)/\x03&/' -e 's/.*\x03//' \
-	      -e 's/,[ \t]*SEN[ \t]*(/, SEN(/g' \
+	    -e 's/,[ \t]*SEN[ \t]*(/, SEN(/g' \
 	| grep ", SEN(" \
 	| sed -e 's/\(.*\"\).*/\1/g' \
-	      -e 's/#64\"/\"/g' \
+	    -e 's/#64\"/\"/g' \
 	| awk '{print $3 " " $1}' \
 	| sort -u \
 	| sed -e 's/|/,/g' \
-	      -e 's/TD,/descriptor,/g' \
-	      -e 's/TF,/file,/g' \
-	      -e 's/TI,/ipc,/g' \
-	      -e 's/TM,/memory,/g' \
-	      -e 's/TN,/network,/g' \
-	      -e 's/TP,/process,/g' \
-	      -e 's/TS,/signal,/g' \
-	      -e 's/[A-Z]\+,//g' \
+	    -e 's/TD,/descriptor,/g' \
+	    -e 's/TF,/file,/g' \
+	    -e 's/TI,/ipc,/g' \
+	    -e 's/TM,/memory,/g' \
+	    -e 's/TN,/network,/g' \
+	    -e 's/TP,/process,/g' \
+	    -e 's/TS,/signal,/g' \
+	    -e 's/[A-Z]\+,//g' \
 	| grep -v '" $' \
 	| sed 's/,$//g' \
 	| awk "{printf \"  <syscall name=%s groups=\\\"%s\\\"/>\n\", \$1, \$2}"
diff --git a/gdb/syscalls/update-linux-from-src.sh b/gdb/syscalls/update-linux-from-src.sh
index c23ffe62404..d4a34da7a58 100755
--- a/gdb/syscalls/update-linux-from-src.sh
+++ b/gdb/syscalls/update-linux-from-src.sh
@@ -22,7 +22,7 @@
 
 pwd=$(pwd -P)
 
-parse_args ()
+parse_args()
 {
     if [ $# -lt 1 ]; then
 	echo "dir argument needed"
@@ -38,7 +38,7 @@ parse_args ()
     fi
 }
 
-gen_from_kernel_headers ()
+gen_from_kernel_headers()
 {
     local f
     f="$1"
@@ -83,7 +83,7 @@ gen_from_kernel_headers ()
     rm -Rf "$tmpdir"
 }
 
-pre ()
+pre()
 {
     local f
     f="$1"
@@ -108,7 +108,7 @@ pre ()
     local year
     year=$(date +%Y)
 
-    cat <<EOF
+    cat << EOF
 <?xml version="1.0"?>
 <!-- Copyright (C) $start_date-$year Free Software Foundation, Inc.
 
@@ -130,13 +130,12 @@ EOF
     echo '<syscalls_info>'
 }
 
-
-post ()
+post()
 {
     echo '</syscalls_info>'
 }
 
-one ()
+one()
 {
     local f
     f="$1"
@@ -157,21 +156,21 @@ one ()
     # Print out num, abi, name.
     grep -v "^#" "$d/$f" \
 	| awk '{print $1, $2, $3}' \
-	      > "$tmp"
+	    > "$tmp"
 
     local decimal
     decimal="[0-9][0-9]*"
     # Print out num, "removed", name.
     grep -E "^# $decimal was sys_*" "$d/$f" \
 	| awk '{print $2, "removed", gensub("^sys_", "", 1, $4)}' \
-	      >> "$tmp"
+	    >> "$tmp"
 
     case $h in
 	arch/arm/include/uapi/asm/unistd.h)
 	    grep '#define __ARM_NR_[a-z].*__ARM_NR_BASE\+' "$d/$h" \
 		| sed 's/#define //;s/__ARM_NR_BASE+//;s/[()]//g;s/__ARM_NR_/ARM_/' \
 		| awk '{print $2 + 0x0f0000, "private", $1}' \
-		      >> "$tmp"
+		    >> "$tmp"
 	    ;;
     esac
 
@@ -228,7 +227,7 @@ one ()
     local n
     n=$i
 
-    for ((i = 0 ; i < n ; i++)); do
+    for ((i = 0; i < n; i++)); do
 	_name=${names[$i]}
 	_abi=${abis[$i]}
 	_num=$((${nums[$i]} + offset))
@@ -249,7 +248,7 @@ one ()
     post
 }
 
-regen ()
+regen()
 {
     local f
     f="$1"
@@ -352,7 +351,7 @@ regen ()
     one "$t" "$abi" "$start_date" "$offset" "$h" > "$f"
 }
 
-main ()
+main()
 {
     shopt -s extglob
 
diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh
index 887aabb79a9..6a106600119 100755
--- a/gdb/syscalls/update-linux.sh
+++ b/gdb/syscalls/update-linux.sh
@@ -48,7 +48,7 @@ esac
 year=$(date +%Y)
 
 (
-    cat <<EOF
+    cat << EOF
 <?xml version="1.0"?>
 <!-- Copyright (C) $startyear-$year Free Software Foundation, Inc.
 
@@ -69,25 +69,25 @@ EOF
 
     echo '<syscalls_info>'
 
-# There are __NR_ and __NR3264_ prefixed syscall numbers, handle them
-# automatically in this script. Here are the examples of the two types:
-#
-# #define __NR_io_setup 0
-# #define __NR3264_fcntl 25
+    # There are __NR_ and __NR3264_ prefixed syscall numbers, handle them
+    # automatically in this script. Here are the examples of the two types:
+    #
+    # #define __NR_io_setup 0
+    # #define __NR3264_fcntl 25
 
     echo '#include <asm/unistd.h>' \
 	| gcc -E - -dD "$@" \
 	| grep -E '#define (__NR_|__NR3264_)' \
 	| while read -r line; do
-	line=$(echo "$line" | awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
+	    line=$(echo "$line" | awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
 	     sub("^#define __NR(3264)?_", ""); print | "sort -k2 -n"}')
-	if [ -z "$line" ]; then
+	    if [ -z "$line" ]; then
 		continue
-	fi
-	name=$(echo "$line" | awk '{print $1}')
-	nr=$(echo "$line" | awk '{print $2}')
-	echo "  <syscall name=\"$name\" number=\"$nr\"/>"
-    done
+	    fi
+	    name=$(echo "$line" | awk '{print $1}')
+	    nr=$(echo "$line" | awk '{print $2}')
+	    echo "  <syscall name=\"$name\" number=\"$nr\"/>"
+	done
 
     echo '</syscalls_info>'
 ) > "$f"
diff --git a/gdb/syscalls/update-netbsd.sh b/gdb/syscalls/update-netbsd.sh
index 1769bc80193..d177c5e9524 100755
--- a/gdb/syscalls/update-netbsd.sh
+++ b/gdb/syscalls/update-netbsd.sh
@@ -28,12 +28,12 @@
 # rather than syscalls.master as syscall.h is easier to parse.
 
 if [ $# -ne 1 ]; then
-   echo "Error: Path to syscall.h missing. Aborting."
-   echo "Usage: update-netbsd.sh <path-to-syscall.h>"
-   exit 1
+    echo "Error: Path to syscall.h missing. Aborting."
+    echo "Usage: update-netbsd.sh <path-to-syscall.h>"
+    exit 1
 fi
 
-cat > netbsd.xml.tmp <<EOF
+cat > netbsd.xml.tmp << EOF
 <?xml version="1.0"?> <!-- THIS FILE IS GENERATED -*- buffer-read-only: t -*-  -->
 <!-- vi:set ro: -->
 <!-- Copyright (C) 2020-2026 Free Software Foundation, Inc.
@@ -61,7 +61,7 @@ awk '
     sub(/^SYS_/,"",$2);
     printf "  <syscall name=\"%s\" number=\"%s\"", $2, $3
     if (sub(/^netbsd[0-9]*_/,"",$2) != 0)
-        printf " alias=\"%s\"", $2
+	printf " alias=\"%s\"", $2
     printf "/>\n"
 }
 /\/\* [0-9]* is obsolete [a-z_]* \*\// {
@@ -71,7 +71,7 @@ awk '
     printf "  <syscall name=\"%s_%s\" number=\"%s\" alias=\"%s\"/>\n", $4, $5, $2, $5
 }' "$1" >> netbsd.xml.tmp
 
-cat >> netbsd.xml.tmp <<EOF
+cat >> netbsd.xml.tmp << EOF
 </syscalls_info>
 EOF
 
diff --git a/gdb/testsuite/lib/dg-add-core-file-count.sh b/gdb/testsuite/lib/dg-add-core-file-count.sh
index 31287b0d467..32d39934edf 100755
--- a/gdb/testsuite/lib/dg-add-core-file-count.sh
+++ b/gdb/testsuite/lib/dg-add-core-file-count.sh
@@ -26,7 +26,11 @@
 # find, wc, etc.  Spawning a subshell isn't strictly needed, but it's
 # clearer.  The "*core*" pattern is this lax in order to find all of
 # "core", "core.PID", "core.<program>.PID", "<program>.core", etc.
-cores=$(set -- *core*; [ $# -eq 1 ] && [ ! -e "$1" ] && shift; echo $#)
+cores=$(
+    set -- *core*
+    [ $# -eq 1 ] && [ ! -e "$1" ] && shift
+    echo $#
+)
 
 # If no cores found, then don't add our summary line.
 if [ "$cores" -eq "0" ]; then
diff --git a/gdb/testsuite/lib/notty-wrap b/gdb/testsuite/lib/notty-wrap
index 98bd0541f81..df4530ed9ee 100755
--- a/gdb/testsuite/lib/notty-wrap
+++ b/gdb/testsuite/lib/notty-wrap
@@ -21,4 +21,4 @@
 # Wrap any passed-in program and args in a pipe, so that the program
 # is started without a terminal.
 
-exec "$@" </dev/null 2>&1 | cat
+exec "$@" < /dev/null 2>&1 | cat
diff --git a/gdb/testsuite/make-check-all.sh b/gdb/testsuite/make-check-all.sh
index 8708ecec1cc..7e7d125e168 100755
--- a/gdb/testsuite/make-check-all.sh
+++ b/gdb/testsuite/make-check-all.sh
@@ -90,7 +90,7 @@ virtual_boards=(
 )
 
 # Get RUNTESTFLAGS needed for specific boards.
-rtf_for_board ()
+rtf_for_board()
 {
     local b
     b="$1"
@@ -128,7 +128,7 @@ rtf_for_board ()
 		)
 	    fi
 	    ;;
-	local-remote-host|local-remote-host-notty)
+	local-remote-host | local-remote-host-notty)
 	    if [ "$host_user" != "" ]; then
 		rtf=(
 		    "${rtf[@]}"
@@ -147,7 +147,7 @@ rtf_for_board ()
 }
 
 # Get make target needed for specific boards.
-maketarget_for_board ()
+maketarget_for_board()
 {
     local b
     b="$1"
@@ -166,7 +166,7 @@ maketarget_for_board ()
 }
 
 # Summarize make check output.
-summary ()
+summary()
 {
     if $verbose; then
 	cat
@@ -179,7 +179,7 @@ summary ()
 }
 
 # Run make check, and possibly save test results.
-do_tests ()
+do_tests()
 {
     if $debug; then
 	echo "RTF: ${rtf[*]}"
@@ -191,8 +191,8 @@ do_tests ()
 
     # Run make check.
     make $maketarget \
-	 RUNTESTFLAGS="${rtf[*]}" TESTS="${tests[*]}" \
-	 2>&1 \
+	RUNTESTFLAGS="${rtf[*]}" TESTS="${tests[*]}" \
+	2>&1 \
 	| summary
 
     # Save test results.
@@ -216,7 +216,7 @@ do_tests ()
 
 	# Record the 'make check' command to enable easy re-running.
 	make_check_script="$dir/make-check.sh"
-	cat <<-EOF > "$make_check_script"
+	cat <<- EOF > "$make_check_script"
 	#!/bin/sh
 
 	cd "$PWD" && \\
@@ -228,7 +228,7 @@ do_tests ()
 
 # Set default values for global vars and modify according to command line
 # arguments.
-parse_args ()
+parse_args()
 {
     # Default values.
     debug=false
@@ -277,7 +277,7 @@ parse_args ()
 }
 
 # Cleanup function, scheduled to run on exit.
-cleanup ()
+cleanup()
 {
     if [ "$tmpdir" != "" ]; then
 	if $keep_tmp; then
@@ -289,7 +289,7 @@ cleanup ()
 }
 
 # Top-level function, called with command line arguments of the script.
-main ()
+main()
 {
     # Parse command line arguments.
     parse_args "$@"
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh
  2026-09-02 13:17 [RFC 0/3] [pre-commit] Add shfmt Tom de Vries
  2026-09-02 13:17 ` [RFC 1/3] " Tom de Vries
  2026-09-02 13:17 ` [RFC 2/3] [pre-commit] Enable shfmt Tom de Vries
@ 2026-09-02 13:17 ` Tom de Vries
  2026-09-15  7:26   ` Tom de Vries
  2 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2026-09-02 13:17 UTC (permalink / raw)
  To: gdb-patches

Use shfmt --simplify in gdb/contrib/shfmt.sh.
---
 gdb/contrib/shfmt.sh | 1 +
 gdb/make-init-c      | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/contrib/shfmt.sh b/gdb/contrib/shfmt.sh
index 0f1cf332b2a..e6ab481e17f 100755
--- a/gdb/contrib/shfmt.sh
+++ b/gdb/contrib/shfmt.sh
@@ -50,6 +50,7 @@ with_indent()
 	--space-redirects \
 	--case-indent \
 	--binary-next-line \
+	--simplify \
 	--write \
 	"$@"
 }
diff --git a/gdb/make-init-c b/gdb/make-init-c
index 47bcfd44533..bb8cc6db1f1 100755
--- a/gdb/make-init-c
+++ b/gdb/make-init-c
@@ -64,7 +64,7 @@ echo ""
 echo "  /* If GDB_REVERSE_INIT_FUNCTIONS is set (any value), reverse the"
 echo "     order in which initialization functions are called.  This is"
 echo "     used by the testsuite.  */"
-echo "  if (getenv (\"GDB_REVERSE_INIT_FUNCTIONS\") != nullptr)"
+echo '  if (getenv ("GDB_REVERSE_INIT_FUNCTIONS") != nullptr)'
 echo "    std::reverse (functions.begin (), functions.end ());"
 echo ""
 echo "  for (initialize_file_ftype *function : functions)"
-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh
  2026-09-02 13:17 ` [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh Tom de Vries
@ 2026-09-15  7:26   ` Tom de Vries
  0 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-15  7:26 UTC (permalink / raw)
  To: gdb-patches

On 9/2/26 3:17 PM, Tom de Vries wrote:
> diff --git a/gdb/make-init-c b/gdb/make-init-c
> index 47bcfd44533..bb8cc6db1f1 100755
> --- a/gdb/make-init-c
> +++ b/gdb/make-init-c
> @@ -64,7 +64,7 @@ echo ""
>   echo "  /* If GDB_REVERSE_INIT_FUNCTIONS is set (any value), reverse the"
>   echo "     order in which initialization functions are called.  This is"
>   echo "     used by the testsuite.  */"
> -echo "  if (getenv (\"GDB_REVERSE_INIT_FUNCTIONS\") != nullptr)"
> +echo '  if (getenv ("GDB_REVERSE_INIT_FUNCTIONS") != nullptr)'
>   echo "    std::reverse (functions.begin (), functions.end ());"
>   echo ""
>   echo "  for (initialize_file_ftype *function : functions)"


I've committed this change as a separate patch (
https://sourceware.org/pipermail/gdb-patches/2026-September/230355.html ).

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-15  7:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 13:17 [RFC 0/3] [pre-commit] Add shfmt Tom de Vries
2026-09-02 13:17 ` [RFC 1/3] " Tom de Vries
2026-09-02 13:17 ` [RFC 2/3] [pre-commit] Enable shfmt Tom de Vries
2026-09-02 13:17 ` [RFC 3/3] [gdb/contrib] Use shfmt --simplify in shfmt.sh Tom de Vries
2026-09-15  7:26   ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox