From 4971cedc2a27fb6c154d9abf3032d6f4a07f7eb8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 26 Jun 2017 11:09:05 +0200 Subject: [PATCH] CONFIG: cleanup bash completions in unset --- bin/tools/foamCreateBashCompletions | 1 + etc/config.sh/bashcompletion | 1 + etc/config.sh/unset | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/bin/tools/foamCreateBashCompletions b/bin/tools/foamCreateBashCompletions index ccc65a2313..f7c384f482 100755 --- a/bin/tools/foamCreateBashCompletions +++ b/bin/tools/foamCreateBashCompletions @@ -97,6 +97,7 @@ done cat << HEADER > $outFile #----------------------------------*-sh-*-------------------------------------- # Bash completions for OpenFOAM applications +# Formatted as "complete ... -F _of_APPNAME APPNAME unset -f _of_filter_opts 2>/dev/null _of_filter_opts() diff --git a/etc/config.sh/bashcompletion b/etc/config.sh/bashcompletion index 82714979d2..27a189a6ce 100644 --- a/etc/config.sh/bashcompletion +++ b/etc/config.sh/bashcompletion @@ -1,5 +1,6 @@ #----------------------------------*-sh-*-------------------------------------- # Bash completions for OpenFOAM applications +# Formatted as "complete ... -F _of_APPNAME APPNAME unset -f _of_filter_opts 2>/dev/null _of_filter_opts() diff --git a/etc/config.sh/unset b/etc/config.sh/unset index d9aa0639eb..95afc82534 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -181,6 +181,17 @@ unset -f wmRefresh 2>/dev/null unset -f foamVersion 2>/dev/null unset -f foamPV 2>/dev/null +# Cleanup bash completions, which look like this: +# "complete ... -F _of_APPNAME APPNAME +# For economy, obtain list first but also add in 'filter_opts' helper +foamClean="$(complete 2>/dev/null | sed -n -e 's/complete.*-F _of_.* \(..*\)$/\1/p')" +for cleaned in $foamClean filter_opts +do + unset -f _of_$cleaned 2>/dev/null + complete -r $cleaned 2>/dev/null +done + + #------------------------------------------------------------------------------ # Intermediate variables (do as last for a clean exit code)