Skip to content

fix: add miscellaneous fixes before implementing _comp_compgen -P #1359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1352,10 +1352,12 @@ _comp_delimited()
# `show-all-if-ambiguous` on, but even that has cases where it fails
# and the last separator including everything before it is lost.
# https://github.com/scop/bash-completion/pull/913#issuecomment-1490140309
local i
for i in "${!COMPREPLY[@]}"; do
COMPREPLY[i]="$prefix${COMPREPLY[i]}"
done
if [[ $prefix ]]; then
local i
for i in "${!COMPREPLY[@]}"; do
COMPREPLY[i]="$prefix${COMPREPLY[i]}"
done
fi

[[ $delimiter != : ]] || _comp_ltrim_colon_completions "$cur"
}
Expand Down
13 changes: 2 additions & 11 deletions completions/cppcheck
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ _comp_cmd_cppcheck()
return
;;
--enable)
# split comma-separated list
local split=""
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
split="set"
fi
_comp_compgen -- -W 'all warning style performance portability
information unusedFunction missingInclude' &&
[[ $split ]] &&
_comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"'
_comp_delimited , -W 'all warning style performance portability
information unusedFunction missingInclude'
return
;;
--error-exitcode)
Expand Down
2 changes: 1 addition & 1 deletion completions/firefox
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ _comp_cmd_firefox()
local cur prev words cword was_split comp_args
_comp_initialize -s -- "$@" || return

[[ $cur == -MOZ_LOG*=* ]] && prev=${cur%%=*} cur=${cur#*=}
[[ ! $was_split && $cur == -MOZ_LOG*=* ]] && prev=${cur%%=*} cur=${cur#*=}

case $prev in
--help | --version | --display | --UILocale | -MOZ_LOG | --new-window | --new-tab | \
Expand Down
4 changes: 2 additions & 2 deletions completions/make
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ _comp_cmd_make()
elif [[ $cur == *=* ]]; then
prev=${cur%%=*}
cur=${cur#*=}
local diropt
local diropt=""
[[ ${prev,,} == *dir?(ectory) ]] && diropt=-d
_comp_compgen_filedir $diropt
_comp_compgen_filedir ${diropt:+"$diropt"}
else
# before we check for makefiles, see if a path was specified
# with -C/--directory
Expand Down
4 changes: 2 additions & 2 deletions completions/openssl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ _comp_cmd_openssl__compgen_digests()
"$1" dgst -h 2>&1 |
_comp_awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }'
)"
_comp_compgen -ac "${cur#-}" split -P "-" -- "$("$1" help 2>&1 |
_comp_compgen_split -- "$("$1" help 2>&1 |
command sed -ne '/^Message Digest commands/,/^[[:space:]]*$/p' |
command sed -e 1d)"
command sed -e '1d;s/^/-/')"
}

_comp_cmd_openssl()
Expand Down
4 changes: 2 additions & 2 deletions completions/strings
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ _comp_cmd_strings()
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
elif [[ $cur == @* ]]; then
_comp_compgen -c "${cur:1}" filedir
COMPREPLY=("${COMPREPLY[@]/#/@}")
_comp_compgen -c "${cur:1}" filedir &&
COMPREPLY=("${COMPREPLY[@]/#/@}")
return
fi

Expand Down
2 changes: 1 addition & 1 deletion completions/tshark
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

_comp_cmd_tshark()
{
local cur prev words cword comp_args prefix
local cur prev words cword comp_args prefix=""
_comp_initialize -n : -- "$@" || return

case $cur in
Expand Down