CONFIG: prevent bash completions from examining the description notes

This commit is contained in:
Mark Olesen 2019-11-25 18:38:39 +01:00 committed by Andrew Heather
parent 6dd3cd0e51
commit f30b0895e8
2 changed files with 8 additions and 0 deletions

View File

@ -155,11 +155,15 @@ HEADER
# - options with '=' (eg, -mode=ugo) are not handled very well at all.
# - alternatives (eg, -a, -all) are not handled nicely either,
# for these treat ',' like a space to catch the worst of them.
#
# Remove anything that starts with more than 8 spaces to avoid parsing
# any of the option description text
extractOptions()
{
local appName="$1"
local helpText=$($appName -help-full 2>/dev/null | \
sed -ne '1,/^[Oo]ptions:/d' \
-e '/^ \{8\}/d;' \
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
-e '/^-hostRoots /d; /^-roots /d;' \
-e '/^-lib /d;' \

View File

@ -146,10 +146,14 @@ _of_complete_()
# - options with '=' (eg, -mode=ugo) are not handled very well at all.
# - alternatives (eg, -a, -all) are not handled nicely either,
# for these treat ',' like a space to catch the worst of them.
#
# Remove anything that starts with more than 8 spaces to avoid parsing
# any of the option description text
if [ -z "$choices" ]
then
local helpText=$($appName -help-full 2>/dev/null | \
sed -ne '1,/^[Oo]ptions:/d' \
-e '/^ \{8\}/d;' \
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
-e 'y/,/ /; s/=.*$/=/;' \
-e '/^-[^ ]* </{ s/^\(-[^ ]* <\).*$/\1/; p; d }' \