From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F33C115817D for ; Fri, 7 Jun 2024 10:20:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 34FA9E2A1B; Fri, 7 Jun 2024 10:20:33 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 112BBE2A1B for ; Fri, 7 Jun 2024 10:20:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 129B434067D for ; Fri, 7 Jun 2024 10:20:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 180351502 for ; Fri, 7 Jun 2024 10:20:30 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1717755364.90dceec2bd0941e9a31fe0b906bdc283869dbca9.arthurzam@gentoo> Subject: [gentoo-commits] proj/gentoo-bashcomp:master commit in: completions/ X-VCS-Repository: proj/gentoo-bashcomp X-VCS-Files: completions/gcc-config X-VCS-Directories: completions/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 90dceec2bd0941e9a31fe0b906bdc283869dbca9 X-VCS-Branch: master Date: Fri, 7 Jun 2024 10:20:30 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4e1c5f91-aa14-4f58-9df3-0c2f72bf1f54 X-Archives-Hash: 5b3ef78d61f3be3002b863aaa7659016 commit: 90dceec2bd0941e9a31fe0b906bdc283869dbca9 Author: Arthur Zamarin gentoo org> AuthorDate: Fri Jun 7 10:16:04 2024 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Fri Jun 7 10:16:04 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-bashcomp.git/commit/?id=90dceec2 gcc-config: fix invalid suggestions & add missing flags It was using the colored output and the "*" as completion options, which was causing weird suggestions. Signed-off-by: Arthur Zamarin gentoo.org> completions/gcc-config | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/completions/gcc-config b/completions/gcc-config index b0d0800..40d8415 100644 --- a/completions/gcc-config +++ b/completions/gcc-config @@ -1,42 +1,46 @@ # Gentoo Linux Bash Shell Command Completion # -# Copyright 1999-2013 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License, v2 or later # -# gcc-config completion command +# gcc-config completion (from sys-devel/gcc-config) # _gcc_config() { - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="-O --use-old \ - -P --use-portage-chost \ - -c --get-current-profile \ - -l --list-profiles \ - -E --print-environ \ - -B --get-bin-path \ - -L --get-lib-path \ - -X --get-stdcxx-incdir" + local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} + local OPTS=( + -C --nocolor + -O --use-old + -f --force + -P --use-portage-chost + -c --get-current-profile + -l --list-profiles + -S --split-profile + -E --print-environ + -B --get-bin-path + -L --get-lib-path + -X --get-stdcxx-incdir + ) + _list_profiles() { + gcc-config --nocolor --list-profiles 2>/dev/null | \ + sed -r -e 's/\[([^]]*)\] //g' -e 's/ \*//g' + } - if [[ "${cur}" == -* ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + if [[ ${cur} == -* ]] ; then + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") ) return 0 elif [[ ${COMP_CWORD} -eq 1 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) \ - $(compgen -W "$(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" \ - -- ${cur}) ) + COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "${cur}") ) + COMPREPLY+=( $(compgen -W '$(_list_profiles)' -- "${cur}" )) return 0 fi - case "${prev}" in + case ${prev} in -O|--use-old|-P|--use-portage-chost|-c|--get-current-profile|-l|--list-profiles) COMPREPLY=() ;; *) - COMPREPLY=( $(compgen -W "\ - $(gcc-config -l | sed -r -e 's/(\[([^]]*)\]) //g')" -- ${cur}) ) + COMPREPLY=( $(compgen -W '$(_list_profiles)' -- "${cur}") ) ;; esac } &&