diff options
author | Tom de Vries <tdevries@suse.de> | 2024-11-18 09:42:04 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-11-18 09:42:04 +0100 |
commit | 57e43f6ea5b14798b7fc2723edf997bd4d8dc90e (patch) | |
tree | 11c6fe8526dd5e22e1a6996341019c94ae1621a3 /gdb/contrib | |
parent | 92a5cfde2f72130aa76bc35e91263c092254ee7c (diff) | |
download | binutils-57e43f6ea5b14798b7fc2723edf997bd4d8dc90e.zip binutils-57e43f6ea5b14798b7fc2723edf997bd4d8dc90e.tar.gz binutils-57e43f6ea5b14798b7fc2723edf997bd4d8dc90e.tar.bz2 |
[gdb/contrib] Add spellcheck.sh --print-dictionary
Add an option --print-dictionary to spellcheck.sh that allows us to inspect
the effective dictionary.
Verified with shellcheck.
Diffstat (limited to 'gdb/contrib')
-rwxr-xr-x | gdb/contrib/spellcheck.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh index 2c34b03..d9ee797 100755 --- a/gdb/contrib/spellcheck.sh +++ b/gdb/contrib/spellcheck.sh @@ -119,6 +119,7 @@ sed_join () usage () { echo "usage: $(basename "$0") [--check] <file|dir>+" + echo " $(basename "$0") --print-dictionary" } make_absolute () @@ -143,6 +144,11 @@ parse_args () files=$(mktemp) trap 'rm -f "$files"' EXIT + if [ $# -eq 1 ] && [ "$1" = "--print-dictionary" ]; then + print_dictionary=true + return + fi + while true; do case " $1 " in " --check ") @@ -259,6 +265,22 @@ parse_dictionary () done } +print_dictionary () +{ + local i word replacement + i=0 + for word in "${words[@]}"; do + replacement=${replacements[$i]} + i=$((i + 1)) + + if [ "$word" == "" ]; then + continue + fi + + echo "$word -> $replacement" + done +} + find_files_matching_words () { local cache_id @@ -424,6 +446,7 @@ main () { declare -a unique_files check=false + print_dictionary=false parse_args "$@" get_dictionary @@ -432,6 +455,11 @@ main () declare -a replacements parse_dictionary + if $print_dictionary; then + print_dictionary + exit 0 + fi + # Reduce set of files for sed to operate on. local files_matching_words declare -a files_matching_words |