1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#!/bin/sh
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
# license: GNU General Public License, version 3
# use same wording, use of bold/underlining:
# code: predefined words: **
# *./script.using.shellia* [**-i|-s|-m**] [**-d**] [--] [*script-specific-options*]
#
# code: free words: *
# *command sequence*
# *./script.using.shellia* [**-i|-s|-m**] [**-d**] [--] [*script-specific-options*]
#
# text: very important in context: **
# **shellia**
# **step**
# **interactive-mode**
# **check-mode**
# **trace-mode**
#
# text: important in context or files: *
# *command sequence*
# *check-mode* option **-c**
# **shellia** is tested successful with *bash*, *dash*, *busybox sh*, *mksh* and *posh*.
A="$(
(
cat shellia-1.rst
cat shellia-3.rst
cat shellia-7.rst
) |
sed "s/^\s*\*\s//" |
sed "s/[^\*]*\(\*\+[^\*]\+\*\+\)/f-o-u-n-d:\1\n/g" | sed -n "s/^f-o-u-n-d://p"
)"
A1REG="^\*[^\*]\+\*$"
A2REG="^\*\*[^\*]\+\*\*$"
A1="$(echo "$A" | grep -e "$A1REG")"
A2="$(echo "$A" | grep -e "$A2REG")"
A3="$(echo "$A" | grep -v -e "$A1REG" -e "$A2REG")"
if [ "$A3" ]; then
echo "ERROR A3=<$A3>"
exit 1
fi
(
echo "$A1"
echo "$A2"
) | sed "s/^\**//" | sort | uniq -c |
sed -e "s/^\(\s*[0-9]\+\s\+-[a-zA-Z]\*\*\)$/OK \1/" | # **-a** **-c** **-C** **-d** **-i** **-m** **-s** **-x**
sed -E -e "s/^(\s*[0-9]+\s+-[a-zA-Z]\|-[a-zA-Z]\*\*)$/OK \1/" | # **-c|-C**
sed -E -e "s/^(\s*[0-9]+\s+-[a-zA-Z]\|-[a-zA-Z]\|-[a-zA-Z]\*\*)$/OK \1/" | # **-i|-s|-m**
sed -E -e "s/^(\s*[0-9]+\s+[a-zA-Z]\*)$/OK \1/" | # *c* *d* *i* *q*
sed -E -e "s/^(\s*[0-9]+\s+[0-9][0-9]?\*)$/OK \1/" | # *1* *99*
sed -E -e "s/^(\s*[0-9]+\s+(([C|c]heck)|([D|d]ebug)|([I|i]nteractive)|([L|l]ogging)|([T|t]race))-mode\*\*)$/OK \1/" | # **trace-mode** ..
sed -E -e "s/^(\s*([3-9]|[0-9][0-9]).*)$/OK \1/" | # matched at least 3 times
cat
|