@@ -1241,7 +1241,7 @@ _comp_variable_assignments()
1241
1241
fi
1242
1242
;;
1243
1243
TERM)
1244
- _terms
1244
+ _comp_compgen_terms
1245
1245
;;
1246
1246
LANG | LC_* )
1247
1247
_comp_compgen_split -- " $( locale -a 2> /dev/null) "
@@ -1527,6 +1527,8 @@ _comp_compgen_usage()
1527
1527
1528
1528
# This function completes on signal names (minus the SIG prefix)
1529
1529
# @param $1 prefix
1530
+ #
1531
+ # @since 2.12
1530
1532
_comp_compgen_signals ()
1531
1533
{
1532
1534
local -a sigs
@@ -1536,6 +1538,7 @@ _comp_compgen_signals()
1536
1538
1537
1539
# This function completes on known mac addresses
1538
1540
#
1541
+ # @since 2.12
1539
1542
_comp_compgen_mac_addresses ()
1540
1543
{
1541
1544
local re=' \([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'
@@ -1574,6 +1577,7 @@ _comp_compgen_mac_addresses()
1574
1577
1575
1578
# This function completes on configured network interfaces
1576
1579
#
1580
+ # @since 2.12
1577
1581
_comp_compgen_configured_interfaces ()
1578
1582
{
1579
1583
local -a files
@@ -1609,6 +1613,7 @@ _comp_compgen_configured_interfaces()
1609
1613
# -6: IPv6 addresses only
1610
1614
# -a: All addresses
1611
1615
#
1616
+ # @since 2.12
1612
1617
_comp_compgen_ip_addresses ()
1613
1618
{
1614
1619
local n
@@ -1633,10 +1638,10 @@ _comp_compgen_ip_addresses()
1633
1638
fi
1634
1639
}
1635
1640
1636
- # This function completes on available kernels
1641
+ # This function completes on available kernel versions
1637
1642
#
1638
- # TODO:API: rename per conventions
1639
- _kernel_versions ()
1643
+ # @since 2.12
1644
+ _comp_compgen_kernel_versions ()
1640
1645
{
1641
1646
_comp_compgen_split -- " $( command ls /lib/modules) "
1642
1647
}
@@ -1645,6 +1650,7 @@ _kernel_versions()
1645
1650
# -a: restrict to active interfaces only
1646
1651
# -w: restrict to wireless interfaces only
1647
1652
#
1653
+ # @since 2.12
1648
1654
_comp_compgen_available_interfaces ()
1649
1655
{
1650
1656
local PATH=$PATH :/sbin
@@ -1750,34 +1756,35 @@ _expand()
1750
1756
1751
1757
# Process ID related functions.
1752
1758
# for AIX and Solaris we use X/Open syntax, BSD for others.
1753
- # TODO:API: rename per conventions
1759
+ #
1760
+ # @since 2.12
1754
1761
if [[ $OSTYPE == * @ (solaris| aix)* ]]; then
1755
1762
# This function completes on process IDs.
1756
- _pids ()
1763
+ _comp_compgen_pids ()
1757
1764
{
1758
1765
_comp_compgen_split -- " $( command ps -efo pid | command sed 1d) "
1759
1766
}
1760
1767
1761
- _pgids ()
1768
+ _comp_compgen_pgids ()
1762
1769
{
1763
1770
_comp_compgen_split -- " $( command ps -efo pgid | command sed 1d) "
1764
1771
}
1765
- _pnames ()
1772
+ _comp_compgen_pnames ()
1766
1773
{
1767
1774
_comp_compgen_split -X ' <defunct>' -- " $( command ps -efo comm |
1768
1775
command sed -e 1d -e ' s:.*/::' -e ' s/^-//' | sort -u) "
1769
1776
}
1770
1777
else
1771
- _pids ()
1778
+ _comp_compgen_pids ()
1772
1779
{
1773
1780
_comp_compgen_split -- " $( command ps ax -o pid=) "
1774
1781
}
1775
- _pgids ()
1782
+ _comp_compgen_pgids ()
1776
1783
{
1777
1784
_comp_compgen_split -- " $( command ps ax -o pgid=) "
1778
1785
}
1779
1786
# @param $1 if -s, don't try to avoid truncated command names
1780
- _pnames ()
1787
+ _comp_compgen_pnames ()
1781
1788
{
1782
1789
local -a procs=()
1783
1790
if [[ ${1-} == -s ]]; then
1829
1836
1830
1837
# This function completes on user IDs
1831
1838
#
1832
- # TODO:API: rename per conventions
1833
- _uids ()
1839
+ # @since 2.12
1840
+ _comp_compgen_uids ()
1834
1841
{
1835
1842
if type getent & > /dev/null; then
1836
1843
_comp_compgen_split -- " $( getent passwd | cut -d: -f3) "
@@ -1844,8 +1851,8 @@ _uids()
1844
1851
1845
1852
# This function completes on group IDs
1846
1853
#
1847
- # TODO:API: rename per conventions
1848
- _gids ()
1854
+ # @since 2.12
1855
+ _comp_compgen_gids ()
1849
1856
{
1850
1857
if type getent & > /dev/null; then
1851
1858
_comp_compgen_split -- " $( getent group | cut -d: -f3) "
@@ -1863,8 +1870,8 @@ _comp_backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|@(dpkg|ucf)-*|rpm@(orig|new|sa
1863
1870
1864
1871
# Complete on xinetd services
1865
1872
#
1866
- # TODO:API: rename per conventions
1867
- _xinetd_services ()
1873
+ # @since 2.12
1874
+ _comp_compgen_xinetd_services ()
1868
1875
{
1869
1876
local xinetddir=${_comp__test_xinetd_dir:-/ etc/ xinetd.d}
1870
1877
if [[ -d $xinetddir ]]; then
@@ -1919,7 +1926,7 @@ _service()
1919
1926
1920
1927
if [[ $cword -eq 1 && $prev == ? (* /)service ]]; then
1921
1928
_services
1922
- [[ -e /etc/mandrake-release ]] && _xinetd_services
1929
+ [[ -e /etc/mandrake-release ]] && _comp_compgen_xinetd_services
1923
1930
else
1924
1931
local sysvdirs
1925
1932
_comp_sysvdirs
@@ -1943,10 +1950,11 @@ _comp__init_set_up_service_completions()
1943
1950
}
1944
1951
_comp__init_set_up_service_completions
1945
1952
1946
- # This function completes on modules
1953
+ # This function completes on kernel modules
1954
+ # @param $1 kernel version
1947
1955
#
1948
- # TODO:API: rename per conventions (+ include "kernel" in the name)
1949
- _modules ()
1956
+ # @since 2.12
1957
+ _comp_compgen_kernel_modules ()
1950
1958
{
1951
1959
local modpath
1952
1960
modpath=/lib/modules/$1
@@ -1955,12 +1963,13 @@ _modules()
1955
1963
-e ' s/^\(.*\)\.ko\.zst$/\1/p' ) "
1956
1964
}
1957
1965
1958
- # This function completes on installed modules
1966
+ # This function completes on inserted kernel modules
1967
+ # @param $1 prefix to filter with, default $cur
1959
1968
#
1960
- # TODO:API: rename per conventions (+ include "kernel" in the name)
1961
- _installed_modules ()
1969
+ # @since 2.12
1970
+ _comp_compgen_inserted_kernel_modules ()
1962
1971
{
1963
- _comp_compgen -c " $1 " split -- " $( PATH=" $PATH :/sbin" lsmod |
1972
+ _comp_compgen -c " ${1 :- $cur } " split -- " $( PATH=" $PATH :/sbin" lsmod |
1964
1973
awk ' {if (NR != 1) print $1}' ) "
1965
1974
}
1966
1975
@@ -1971,8 +1980,9 @@ _installed_modules()
1971
1980
#
1972
1981
# @param $1 If -u, only return users/groups the user has access to in
1973
1982
# context of current completion.
1974
- # TODO:API: rename per conventions
1975
- _usergroup ()
1983
+ #
1984
+ # @since 2.12
1985
+ _comp_compgen_usergroup ()
1976
1986
{
1977
1987
if [[ $cur == * \\\\ * || $cur == * :* :* ]]; then
1978
1988
# Give up early on if something seems horribly wrong.
@@ -1986,7 +1996,7 @@ _usergroup()
1986
1996
prefix=${prefix// \\ / }
1987
1997
local mycur=${cur#* [:]}
1988
1998
if [[ ${1-} == -u ]]; then
1989
- _allowed_groups " $mycur "
1999
+ _comp_compgen -c " $mycur " allowed_groups
1990
2000
else
1991
2001
_comp_compgen -c " $mycur " -- -g
1992
2002
fi
@@ -1998,7 +2008,7 @@ _usergroup()
1998
2008
# and only replace the 'gr' part
1999
2009
local mycur=${cur#*: }
2000
2010
if [[ ${1-} == -u ]]; then
2001
- _allowed_groups " $mycur "
2011
+ _comp_compgen -c " $mycur " allowed_groups
2002
2012
else
2003
2013
_comp_compgen -c " $mycur " -- -g
2004
2014
fi
@@ -2009,32 +2019,30 @@ _usergroup()
2009
2019
# slash. It's better to complete into 'chown username ' than 'chown
2010
2020
# username\:'.
2011
2021
if [[ ${1-} == -u ]]; then
2012
- _allowed_users " $cur "
2022
+ _comp_compgen_allowed_users
2013
2023
else
2014
2024
_comp_compgen -- -u
2015
2025
fi
2016
2026
fi
2017
2027
}
2018
2028
2019
- # TODO:API: rename per conventions
2020
- _allowed_users ()
2029
+ # @since 2.12
2030
+ _comp_compgen_allowed_users ()
2021
2031
{
2022
- if _complete_as_root ; then
2023
- _comp_compgen -c " ${1 :- $cur } " - - -u
2032
+ if _comp_as_root ; then
2033
+ _comp_compgen -- -u
2024
2034
else
2025
- _comp_compgen -c " ${1:- $cur } " split -- " $( id -un 2> /dev/null ||
2026
- whoami 2> /dev/null) "
2035
+ _comp_compgen split -- " $( id -un 2> /dev/null || whoami 2> /dev/null) "
2027
2036
fi
2028
2037
}
2029
2038
2030
- # TODO:API: rename per conventions
2031
- _allowed_groups ()
2039
+ # @since 2.12
2040
+ _comp_compgen_allowed_groups ()
2032
2041
{
2033
- if _complete_as_root ; then
2034
- _comp_compgen -c " $1 " - - -g
2042
+ if _comp_as_root ; then
2043
+ _comp_compgen -- -g
2035
2044
else
2036
- _comp_compgen -c " $1 " split -- " $( id -Gn 2> /dev/null ||
2037
- groups 2> /dev/null) "
2045
+ _comp_compgen split -- " $( id -Gn 2> /dev/null || groups 2> /dev/null) "
2038
2046
fi
2039
2047
}
2040
2048
@@ -2059,8 +2067,8 @@ _shells()
2059
2067
2060
2068
# This function completes on valid filesystem types
2061
2069
#
2062
- # TODO:API: rename per conventions
2063
- _fstypes ()
2070
+ # @since 2.12
2071
+ _comp_compgen_fstypes ()
2064
2072
{
2065
2073
local fss
2066
2074
@@ -2078,7 +2086,7 @@ _fstypes()
2078
2086
$( [[ -d /etc/fs ]] && command ls /etc/fs) "
2079
2087
fi
2080
2088
2081
- [[ $fss ]] && _comp_compgen -a - - -W " $fss "
2089
+ [[ $fss ]] && _comp_compgen -- -W " $fss "
2082
2090
}
2083
2091
2084
2092
# Get absolute path to a file, with rudimentary canonicalization.
@@ -2164,38 +2172,40 @@ _count_args()
2164
2172
2165
2173
# This function completes on PCI IDs
2166
2174
#
2167
- # TODO:API: rename per conventions
2168
- _pci_ids ()
2175
+ # @since 2.12
2176
+ _comp_compgen_pci_ids ()
2169
2177
{
2170
- _comp_compgen -a split -- " $( PATH=" $PATH :/sbin" lspci -n |
2171
- awk ' {print $3}' ) "
2178
+ _comp_compgen_split -- " $( PATH=" $PATH :/sbin" lspci -n | awk ' {print $3}' ) "
2172
2179
}
2173
2180
2174
2181
# This function completes on USB IDs
2175
2182
#
2176
- # TODO:API: rename per conventions
2177
- _usb_ids ()
2183
+ # @since 2.12
2184
+ _comp_compgen_usb_ids ()
2178
2185
{
2179
- _comp_compgen -a split -- " $( PATH=" $PATH :/sbin" lsusb | awk ' {print $6}' ) "
2186
+ _comp_compgen_split -- " $( PATH=" $PATH :/sbin" lsusb | awk ' {print $6}' ) "
2180
2187
}
2181
2188
2182
2189
# CD device names
2183
- # TODO:API: rename per conventions
2184
- _cd_devices ()
2190
+ #
2191
+ # @since 2.12
2192
+ _comp_compgen_cd_devices ()
2185
2193
{
2186
- _comp_compgen -ac " ${cur:-/ dev/ } " -- -f -d -X " !*/?([amrs])cd*"
2194
+ _comp_compgen -c " ${cur:-/ dev/ } " -- -f -d -X " !*/?([amrs])cd*"
2187
2195
}
2188
2196
2189
2197
# DVD device names
2190
- # TODO:API: rename per conventions
2191
- _dvd_devices ()
2198
+ #
2199
+ # @since 2.12
2200
+ _comp_compgen_dvd_devices ()
2192
2201
{
2193
- _comp_compgen -ac " ${cur:-/ dev/ } " -- -f -d -X " !*/?(r)dvd*"
2202
+ _comp_compgen -c " ${cur:-/ dev/ } " -- -f -d -X " !*/?(r)dvd*"
2194
2203
}
2195
2204
2196
2205
# TERM environment variable values
2197
- # TODO:API: rename per conventions
2198
- _terms ()
2206
+ #
2207
+ # @since 2.12
2208
+ _comp_compgen_terms ()
2199
2209
{
2200
2210
_comp_compgen -a split -- " $( {
2201
2211
command sed -ne ' s/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap
@@ -2724,8 +2734,9 @@ _comp_root_command()
2724
2734
complete -F _comp_root_command fakeroot gksu gksudo kdesudo really
2725
2735
2726
2736
# Return true if the completion should be treated as running as root
2727
- # TODO:API: rename per conventions
2728
- _complete_as_root ()
2737
+ #
2738
+ # @since 2.12
2739
+ _comp_as_root ()
2729
2740
{
2730
2741
[[ $EUID -eq 0 || ${root_command-} ]]
2731
2742
}
0 commit comments