From a66e9c7468bdab181352ae555ea007b7f34a9e6a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 12 Dec 2018 03:07:14 +0100 Subject: [PATCH] ENH: adjust completion parser - restrict to text between "^[Oo]ptions:" and "-help-full" to avoid potential issues when more text is introduced in the usage output. --- bin/tools/foamCreateCompletionCache | 6 ++++-- etc/config.sh/bash_completion | 6 ++++-- src/OpenFOAM/global/argList/argListHelp.C | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/tools/foamCreateCompletionCache b/bin/tools/foamCreateCompletionCache index 0e1e81bf1e..f6c23e30e9 100755 --- a/bin/tools/foamCreateCompletionCache +++ b/bin/tools/foamCreateCompletionCache @@ -147,7 +147,8 @@ HEADER # -hostRoots Advanced distributed run option # -roots Advanced distributed run option # -# Terminate parsing on first appearance of -help-full. +# Begin parsing after first appearance of "^[Oo]ptions:" +# Terminate parsing on first appearance of "-help-full" # - 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. @@ -155,7 +156,8 @@ extractOptions() { local appName="$1" local helpText=$($appName -help-full 2>/dev/null | \ - sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \ + sed -ne '1,/^[Oo]ptions:/d' \ + -e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \ -e '/^-hostRoots /d; /^-roots /d;' \ -e 'y/,/ /; s/=.*$/=/;' \ -e '/^-[^ ]* descrip # -help-full # Ignore -help-man (internal option). - # Terminate parsing on first appearance of -help-full + # Begin parsing after first appearance of "^[Oo]ptions:" + # Terminate parsing on first appearance of "-help-full" # - 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. if [ -z "$choices" ] then local helpText=$($appName -help-full 2>/dev/null | \ - sed -ne 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \ + sed -ne '1,/^[Oo]ptions:/d' \ + -e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \ -e 'y/,/ /; s/=.*$/=/;' \ -e '/^-[^ ]*