diff options
author | Tom de Vries <tdevries@suse.de> | 2024-10-08 08:24:13 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-10-08 08:24:13 +0200 |
commit | 99fd53b19dddeb232e169cc5a3918a2adf7d3da2 (patch) | |
tree | 865a3b2116b971868b10ac9e19dff5f75b720c7d /gdb/contrib | |
parent | 124deb310116982fbd921ab1dc83fa75a8252391 (diff) | |
download | gdb-99fd53b19dddeb232e169cc5a3918a2adf7d3da2.zip gdb-99fd53b19dddeb232e169cc5a3918a2adf7d3da2.tar.gz gdb-99fd53b19dddeb232e169cc5a3918a2adf7d3da2.tar.bz2 |
[gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh
While trying to add more separators here:
...
# Separators: space, slash, tab.
grep_separator=" |/| "
sed_separator=" \|/\|\t"
...
I mistakingly used "|" instead of "\|" in sed_separator.
Factor out new variables grep_or and sed_or, and construct the grep_separator
and sed_separator variables by joining the elements of a list using grep_or
and sed_or.
Verified with shellcheck, and tested by rerunning on x86_64-linux.
Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Diffstat (limited to 'gdb/contrib')
-rwxr-xr-x | gdb/contrib/spellcheck.sh | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh index e7db621..343a43f 100755 --- a/gdb/contrib/spellcheck.sh +++ b/gdb/contrib/spellcheck.sh @@ -27,8 +27,47 @@ cache_file=wikipedia-common-misspellings.txt dictionary=$cache_dir/$cache_file # Separators: space, slash, tab. -grep_separator=" |/| " -sed_separator=" \|/\|\t" +declare -a grep_separators +grep_separators=( + " " + "/" + " " +) +declare -a sed_separators +sed_separators=( + " " + "/" + "\t" +) + +join () +{ + local or + or="$1" + shift + + local res + res="" + + local first + first=true + + for item in "$@"; do + if $first; then + first=false + res="$item" + else + res="$res$or$item" + fi + done + + echo "$res" +} + +grep_or="|" +sed_or="\|" +grep_separator=$(join $grep_or "${grep_separators[@]}") +sed_separator=$(join $sed_or "${sed_separators[@]}") usage () { |