[1/3,gdb/contrib] Add spellcheck.sh --check

Message ID 20241008074402.10374-1-tdevries@suse.de
State Committed
Headers
Series [1/3,gdb/contrib] Add spellcheck.sh --check |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries Oct. 8, 2024, 7:44 a.m. UTC
  Add a new option --check to gdb/contrib/spellcheck.sh, to do the spell
check and bail out ASAP with an exit code of 1 if misspelled words were
found, or 0 otherwise.

Verified with shellcheck.
---
 gdb/contrib/spellcheck.sh | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)


base-commit: e808bbbe37dda4a3ec5872ff990090cc746ad7ac
  

Patch

diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh
index 4203333b846..3188734331c 100755
--- a/gdb/contrib/spellcheck.sh
+++ b/gdb/contrib/spellcheck.sh
@@ -76,7 +76,7 @@  sed_separator=$(join $sed_or "${sed_separators[@]}")
 
 usage ()
 {
-    echo "usage: $(basename "$0") <file|dir>+"
+    echo "usage: $(basename "$0") [--check] <file|dir>+"
 }
 
 make_absolute ()
@@ -101,6 +101,18 @@  parse_args ()
     files=$(mktemp)
     trap 'rm -f "$files"' EXIT
 
+    while true; do
+	case " $1 " in
+	    " --check ")
+		check=true
+		shift
+		;;
+	    *)
+		break
+		;;
+	esac
+    done
+
     if [ $# -eq -0 ]; then
 	usage
 	exit 1
@@ -311,6 +323,7 @@  replace_word_in_files ()
 main ()
 {
     declare -a unique_files
+    check=false
     parse_args "$@"
 
     get_dictionary
@@ -329,6 +342,10 @@  main ()
 	return
     fi
 
+    if $check; then
+	exit 1
+    fi
+
     declare -A words_done
     local i word replacement
     i=0