From 0003eb0fb61e9a56f1cdcc87aed60dd249e29019 Mon Sep 17 00:00:00 2001 From: Aditya Merchant Date: Thu, 26 Nov 2026 13:02:06 +0530 Subject: [PATCH] cmake: fix words shift before calling make or ninja completion _cmake_generator_options removes the words before "--" so that make's or ninja's completion only sees the native build tool arguments, but it was written as `shift (( $2 - 1 )) words`. Without the `$`, `(( $2 - 1 ))` is a glob pattern, not arithmetic. The completion system turns on nullglob, so the pattern expands to nothing and shift removes only one word, while CURRENT is still moved back by $2 - 1. The build tool's completion then looks at the wrong word. For example `cmake --build build -- -t ` offered cmake options or ninja targets instead of ninja's subtools, `-C ` offered ninja targets instead of directories, and with Makefiles `-f ` mixed make targets and variables into the file list. --- src/_cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_cmake b/src/_cmake index 38b6954..72543de 100644 --- a/src/_cmake +++ b/src/_cmake @@ -134,7 +134,7 @@ local -a cmake_build_options=( (( $+functions[_cmake_generator_options] )) || _cmake_generator_options() { # pass only the part of the command line starting at "--" to the completion - shift (( $2 - 1 )) words + shift $(( $2 - 1 )) words (( CURRENT = $CURRENT + 1 - $2 )) if [ -f $1/Makefile ] then