[cmake-developers] bash-completion: filtering out version line more robustly

Brad King brad.king at kitware.com
Wed Sep 25 12:46:55 EDT 2013


On 09/25/2013 12:18 PM, Eric Noulard wrote:
> I think it would be simpler to use
> 
> grep -v " "
> 
> because help-*-list never contains a space (no variable or command
> have embedded space)

That's a much stronger assumption that is less future-proof.

In the long run I don't want to do any filtering at all and just
make sure the --help-*-list options display exactly what they should
and nothing more.  For now we need to tolerate existing CMake
behavior with the most specific filter possible.

> I think you missed a couple of cases in the cmake completion.

The only "tail" filters I left are in cache variable list output
which is not filtering out the version line.  A diff between mine
and yours shows that you missed one in cpack:

diff --git a/Docs/bash-completion/cpack b/Docs/bash-completion/cpack
index e3f611e..6df0e41 100644
--- a/Docs/bash-completion/cpack
+++ b/Docs/bash-completion/cpack
@@ -20,7 +20,7 @@ _cpack()
         -D)
             [[ $cur == *=* ]] && return # no completion for values
             COMPREPLY=( $( compgen -W '$( cpack --help-variable-list \
-                2>/dev/null | grep -v "^cmake version " )' -S = -- "$cur" ) )
+                2>/dev/null | tail -n +2 )' -S = -- "$cur" ) )
             compopt -o nospace
             return
             ;;

Anyway, I still prefer my proposal.  Please check that it works
for you as I never actually use this myself.

> Sidenote along bash completion feature:
> 
> completion of variables containing < > are not working that well

If someone knows how to improve this I would welcome it but that
is outside the scope of my change in question.

Thanks,
-Brad



More information about the cmake-developers mailing list