Skip to content

Commit 0783c29

Browse files
authored
Merge pull request #1052 from akinomyoga/misc-1
fix: add misc fixes (misc-1)
2 parents 24c80c9 + 2529d40 commit 0783c29

File tree

13 files changed

+26
-21
lines changed

13 files changed

+26
-21
lines changed

bash_completion

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ _comp_split()
372372
shift "$((OPTIND - 1))"
373373
if (($# != 2)); then
374374
printf '%s\n' "bash_completion: $FUNCNAME: unexpected number of arguments" >&2
375-
printf '%s\n' "usage: $FUNCNAME [-a] [-F SEP] ARRAY_NAME TEXT" >&2
375+
printf '%s\n' "usage: $FUNCNAME [-al] [-F SEP] ARRAY_NAME TEXT" >&2
376376
return 2
377377
elif [[ $1 == @(*[^_a-zA-Z0-9]*|[0-9]*|''|_*|IFS|OPTIND|OPTARG|OPTERR) ]]; then
378378
printf '%s\n' "bash_completion: $FUNCNAME: invalid array name '$1'" >&2
@@ -420,8 +420,8 @@ _comp_compgen__error_fallback()
420420
# -a Append to the array
421421
# -v arr Store the results to the array ARR. The default is `COMPREPLY`.
422422
# The array name should not start with an underscores "_", which is
423-
# internally used. The array name should not be either "IFS" or
424-
# "OPT{IND,ARG,ERR}".
423+
# internally used. The array name should not be any of "cur", "IFS"
424+
# or "OPT{IND,ARG,ERR}".
425425
# -U var Unlocalize VAR before performing the assignments. This option can
426426
# be specified multiple times to register multiple variables. This
427427
# option is supposed to be used in implementing a generator (G1) when
@@ -538,7 +538,7 @@ _comp_compgen()
538538
case $_opt in
539539
a) _append=set ;;
540540
v)
541-
if [[ $OPTARG == @(*[^_a-zA-Z0-9]*|[0-9]*|''|_*|IFS|OPTIND|OPTARG|OPTERR) ]]; then
541+
if [[ $OPTARG == @(*[^_a-zA-Z0-9]*|[0-9]*|''|_*|IFS|OPTIND|OPTARG|OPTERR|cur) ]]; then
542542
printf 'bash_completion: %s: -v: invalid array name `%s'\''\n' "$FUNCNAME" "$OPTARG" >&2
543543
return 2
544544
fi
@@ -548,7 +548,7 @@ _comp_compgen()
548548
if [[ $OPTARG == @(*[^_a-zA-Z0-9]*|[0-9]*|'') ]]; then
549549
printf 'bash_completion: %s: -U: invalid variable name `%s'\''\n' "$FUNCNAME" "$OPTARG" >&2
550550
return 2
551-
elif [[ $OPTARG == @(_*|IFS|OPTIND|OPTARG|OPTERR) ]]; then
551+
elif [[ $OPTARG == @(_*|IFS|OPTIND|OPTARG|OPTERR|cur) ]]; then
552552
printf 'bash_completion: %s: -U: unnecessary to mark `%s'\'' as upvar\n' "$FUNCNAME" "$OPTARG" >&2
553553
return 2
554554
fi
@@ -954,9 +954,11 @@ _comp_get_words()
954954
upvars+=("$vcword")
955955
upargs+=(-v "$vcword" "$cword")
956956
}
957-
[[ $vprev && $cword -ge 1 ]] && {
957+
[[ $vprev ]] && {
958+
local value=""
959+
((cword >= 1)) && value=${words[cword - 1]}
958960
upvars+=("$vprev")
959-
upargs+=(-v "$vprev" "${words[cword - 1]}")
961+
upargs+=(-v "$vprev" "$value")
960962
}
961963
[[ $vwords ]] && {
962964
# Note: bash < 4.4 has a bug that all the elements are connected with
@@ -1333,7 +1335,7 @@ _comp_variable_assignments()
13331335
# @since 2.12
13341336
_comp_initialize()
13351337
{
1336-
local exclude="" opt_split="" outx errx inx
1338+
local exclude="" opt_split="" outx="" errx="" inx=""
13371339

13381340
local flag OPTIND=1 OPTARG="" OPTERR=0
13391341
while getopts "n:e:o:i:s" flag "$@"; do
@@ -1983,10 +1985,11 @@ _service()
19831985

19841986
_comp__init_set_up_service_completions()
19851987
{
1986-
local sysvdirs svc svcdir
1988+
local sysvdirs svc svcdir svcs
19871989
_comp_sysvdirs &&
19881990
for svcdir in "${sysvdirs[@]}"; do
1989-
for svc in "$svcdir"/!($_comp_backup_glob); do
1991+
_comp_expand_glob svcs '"$svcdir"/!($_comp_backup_glob)'
1992+
for svc in "${svcs[@]}"; do
19901993
[[ -x $svc ]] && complete -F _service "$svc"
19911994
done
19921995
done

bash_completion.d/000_bash_completion_compat.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Deprecated bash_completion functions and variables -*- shell-script -*-
1+
# Deprecated bash_completion functions and variables -*- shell-script -*-
22

33
_comp_deprecate_func 2.12 _userland _comp_userland
44
_comp_deprecate_func 2.12 _sysvdirs _comp_sysvdirs

completions/acpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# acpi(1) completion -*- shell-script -*-
1+
# acpi(1) completion -*- shell-script -*-
22

33
_comp_cmd_acpi()
44
{

completions/apt-mark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Debian apt-mark(8) completion -*- shell-script -*-
1+
# Debian apt-mark(8) completion -*- shell-script -*-
22

33
_comp_cmd_apt_mark()
44
{

completions/arp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# arp(8) completion -*- shell-script -*-
1+
# arp(8) completion -*- shell-script -*-
22

33
_comp_cmd_arp()
44
{

completions/bts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# bts completion -*- shell-script -*-
1+
# bts completion -*- shell-script -*-
22

33
# Generate bug numbers from bugs cache in ~/.devscripts_cache/bts
44
_comp_cmd_bts__compgen_cached_bugs()

completions/dmypy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _comp_cmd_dmypy()
1515
;;
1616
esac
1717

18-
local cmd has_cmd="" i
18+
local cmd="" has_cmd="" i
1919
for ((i = 1; i < cword; i++)); do
2020
if [[ ${words[i]} != -* && ${words[i - 1]} != --status-file ]]; then
2121
cmd=${words[i]}

completions/make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ EOF
8888
EOF
8989
}
9090

91-
# Truncate the non-unique filepaths in COMPRELY to only generate unique
91+
# Truncate the non-unique filepaths in COMPREPLY to only generate unique
9292
# directories or files. This function discards the files under subdirectories
9393
# unless the path is unique under each subdirectory and instead generate the
9494
# subdirectory path. For example, when there are two candidates, "abc/def" and

completions/pkgrm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pkgrm completion -*- shell-script -*-
1+
# pkgrm completion -*- shell-script -*-
22
#
33
# Copyright 2006 Yann Rouillard <[email protected]>
44

completions/pkgutil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pkgutil completion -*- shell-script -*-
1+
# pkgutil completion -*- shell-script -*-
22
# Copyright 2006 Yann Rouillard <[email protected]>
33

44
_comp_cmd_pkgutil__url2catalog()

completions/uscan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# uscan completion -*- shell-script -*-
1+
# uscan completion -*- shell-script -*-
22

33
_comp_cmd_uscan()
44
{

test/config/bashrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ _comp__test_get_env()
6767
(
6868
# Do not output the state of test variables "_comp__test_+([0-9])_*"
6969
# and internal mutable variables "_comp_*_mut_*".
70+
local IFS=$' \t\n'
7071
# shellcheck disable=SC2046
7172
unset -v $(compgen -W '"${!_comp_@}"' -X '!_comp_@(_test_+([0-9])_*|*_mut_*)')
73+
_comp_unlocal IFS
7274

7375
set -o posix
7476
set

test/t/unit/test_unit_initialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@pytest.mark.bashcomp(
77
cmd=None,
88
ignore_env=r"^[+-](COMP(_(WORDS|CWORD|LINE|POINT)|REPLY)|"
9-
r"cur|cword|words)=|^\+declare -f _cmd1$",
9+
r"cur|prev|cword|words)=|^\+declare -f _cmd1$",
1010
)
1111
class TestUnitInitCompletion(TestUnitBase):
1212
def test_1(self, bash):

0 commit comments

Comments
 (0)