Browse Source

Revise help system in dejagnu launcher to use Awk

dejagnu-1.6.3
Jacob Bachmeyer 5 years ago
parent
commit
e2fa0bcf54
  1. 4
      ChangeLog
  2. 18
      dejagnu

4
ChangeLog

@ -8,6 +8,10 @@
* dejagnu: Use shell "case" pattern match instead of non-portable
"grep -q" to determine if "awk" is GNU Awk.
* dejagnu: Use Awk instead of non-portable "grep -q" to verify
that a file contains a help message. Also use Awk to extract help
messages from files, instead of a complex dynamic sed(1) program.
2021-04-15 Jacob Bachmeyer <jcb@gnu.org>
PR47382

18
dejagnu

@ -418,21 +418,15 @@ if $want_help ; then
echo ERROR: file "'$help_file'" is not readable
exit 2
fi
if grep -q '#help' "$help_file" \
&& grep -q '#end' "$help_file"; then : ; else
if awk '/#help$/ { pfxlen = length($0) - 4 }
pfxlen && substr($0, pfxlen) == "#end" { exit 1 }
' "$help_file" ; then
echo ERROR: file "'$help_file'" does not contain a help message
exit 2
fi
help_prefix_pat=`grep '#help' "$help_file" \
| sed -e 's/#help.*$//' -e '1q' | tr '[:print:][:blank:]' .`
if expr "$verbose" \> 1 > /dev/null ; then
echo Extracting help from "'$help_file'" with prefix "'$help_prefix_pat'"
fi
sed -n < "$help_file" \
-e '1,/#help/d' \
-e '/^'"$help_prefix_pat"'#end/q' \
-e 's/^'"$help_prefix_pat"'//;p'
exit 0
exec awk '/#help$/ { pfxlen = length($0) - 4 }
pfxlen && substr($0, pfxlen) == "#end" { exit 0 }
pfxlen { print substr($0, pfxlen) }' "$help_file"
fi
if test -z "$command" ; then

Loading…
Cancel
Save