mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
bash-completion: Fix spurious 'following' target completion candidate
The '--target' completion parsed 'cmake --build --target help' with a sed pattern whose leading '...' matched any three characters, so the header line yielded a bogus 'following' candidate. Anchor the pattern to literal dots. Also note in the user-interaction guide that 'make' target tab-completion is provided by the external bash-completion package, which may hide the plain '<target>' name when a '<target>/fast' variant exists, and recommend 'cmake --build --target' completion instead. Fixes: #27873
This commit is contained in:
@@ -131,7 +131,7 @@ _cmake()
|
||||
COMPREPLY=( $( compgen -W "$target_options" -- "$quoted" ) )
|
||||
else
|
||||
local targets=$( cmake --build "$build_dir" --target help 2>/dev/null \
|
||||
| sed -n -e 's/^... \([^ ]*\).*$/\1/p' \
|
||||
| sed -n -e 's/^\.\.\. \([^ ]*\).*$/\1/p' \
|
||||
-e '/^\[/d' -e 's/^\([^ :]*\):.*$/\1/p' | \
|
||||
grep -v '^/' | sort -u )
|
||||
COMPREPLY=( $( compgen -W "$targets $target_options" -- "$quoted" ) )
|
||||
|
||||
@@ -618,6 +618,18 @@ are not rebuilt if out of date. The :ref:`Ninja Generators`
|
||||
are sufficiently fast at dependency checking that
|
||||
such targets are not provided for that generator.
|
||||
|
||||
.. note::
|
||||
|
||||
Shell tab-completion of ``make`` target names is provided
|
||||
by the external ``bash-completion`` package, not by CMake.
|
||||
Some versions of it hide the plain ``<target>`` name when a
|
||||
``<target>/fast`` variant also exists, treating the ``/`` as
|
||||
a directory separator. The targets themselves remain
|
||||
available to build. To complete project target names
|
||||
reliably, use :option:`--target <cmake--build --target>`
|
||||
completion instead, e.g. tab-completion after
|
||||
``cmake --build <dir> --target``.
|
||||
|
||||
:ref:`Makefile Generators` also provide build-targets to
|
||||
preprocess, assemble and compile individual files in a
|
||||
particular directory.
|
||||
|
||||
Reference in New Issue
Block a user