@@ -1241,7 +1241,7 @@ _comp_variable_assignments()
12411241 fi
12421242 ;;
12431243 TERM)
1244- _terms
1244+ _comp_compgen_terms
12451245 ;;
12461246 LANG | LC_* )
12471247 _comp_compgen_split -- " $( locale -a 2> /dev/null) "
@@ -1527,6 +1527,8 @@ _comp_compgen_usage()
15271527
15281528# This function completes on signal names (minus the SIG prefix)
15291529# @param $1 prefix
1530+ #
1531+ # @since 2.12
15301532_comp_compgen_signals ()
15311533{
15321534 local -a sigs
@@ -1536,6 +1538,7 @@ _comp_compgen_signals()
15361538
15371539# This function completes on known mac addresses
15381540#
1541+ # @since 2.12
15391542_comp_compgen_mac_addresses ()
15401543{
15411544 local re=' \([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'
@@ -1574,6 +1577,7 @@ _comp_compgen_mac_addresses()
15741577
15751578# This function completes on configured network interfaces
15761579#
1580+ # @since 2.12
15771581_comp_compgen_configured_interfaces ()
15781582{
15791583 local -a files
@@ -1609,6 +1613,7 @@ _comp_compgen_configured_interfaces()
16091613# -6: IPv6 addresses only
16101614# -a: All addresses
16111615#
1616+ # @since 2.12
16121617_comp_compgen_ip_addresses ()
16131618{
16141619 local n
@@ -1633,10 +1638,10 @@ _comp_compgen_ip_addresses()
16331638 fi
16341639}
16351640
1636- # This function completes on available kernels
1641+ # This function completes on available kernel versions
16371642#
1638- # TODO:API: rename per conventions
1639- _kernel_versions ()
1643+ # @since 2.12
1644+ _comp_compgen_kernel_versions ()
16401645{
16411646 _comp_compgen_split -- " $( command ls /lib/modules) "
16421647}
@@ -1645,6 +1650,7 @@ _kernel_versions()
16451650# -a: restrict to active interfaces only
16461651# -w: restrict to wireless interfaces only
16471652#
1653+ # @since 2.12
16481654_comp_compgen_available_interfaces ()
16491655{
16501656 local PATH=$PATH :/sbin
@@ -1750,34 +1756,35 @@ _expand()
17501756
17511757# Process ID related functions.
17521758# for AIX and Solaris we use X/Open syntax, BSD for others.
1753- # TODO:API: rename per conventions
1759+ #
1760+ # @since 2.12
17541761if [[ $OSTYPE == * @ (solaris| aix)* ]]; then
17551762 # This function completes on process IDs.
1756- _pids ()
1763+ _comp_compgen_pids ()
17571764 {
17581765 _comp_compgen_split -- " $( command ps -efo pid | command sed 1d) "
17591766 }
17601767
1761- _pgids ()
1768+ _comp_compgen_pgids ()
17621769 {
17631770 _comp_compgen_split -- " $( command ps -efo pgid | command sed 1d) "
17641771 }
1765- _pnames ()
1772+ _comp_compgen_pnames ()
17661773 {
17671774 _comp_compgen_split -X ' <defunct>' -- " $( command ps -efo comm |
17681775 command sed -e 1d -e ' s:.*/::' -e ' s/^-//' | sort -u) "
17691776 }
17701777else
1771- _pids ()
1778+ _comp_compgen_pids ()
17721779 {
17731780 _comp_compgen_split -- " $( command ps ax -o pid=) "
17741781 }
1775- _pgids ()
1782+ _comp_compgen_pgids ()
17761783 {
17771784 _comp_compgen_split -- " $( command ps ax -o pgid=) "
17781785 }
17791786 # @param $1 if -s, don't try to avoid truncated command names
1780- _pnames ()
1787+ _comp_compgen_pnames ()
17811788 {
17821789 local -a procs=()
17831790 if [[ ${1-} == -s ]]; then
18291836
18301837# This function completes on user IDs
18311838#
1832- # TODO:API: rename per conventions
1833- _uids ()
1839+ # @since 2.12
1840+ _comp_compgen_uids ()
18341841{
18351842 if type getent & > /dev/null; then
18361843 _comp_compgen_split -- " $( getent passwd | cut -d: -f3) "
@@ -1844,8 +1851,8 @@ _uids()
18441851
18451852# This function completes on group IDs
18461853#
1847- # TODO:API: rename per conventions
1848- _gids ()
1854+ # @since 2.12
1855+ _comp_compgen_gids ()
18491856{
18501857 if type getent & > /dev/null; then
18511858 _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
18631870
18641871# Complete on xinetd services
18651872#
1866- # TODO:API: rename per conventions
1867- _xinetd_services ()
1873+ # @since 2.12
1874+ _comp_compgen_xinetd_services ()
18681875{
18691876 local xinetddir=${_comp__test_xinetd_dir:-/ etc/ xinetd.d}
18701877 if [[ -d $xinetddir ]]; then
@@ -1919,7 +1926,7 @@ _service()
19191926
19201927 if [[ $cword -eq 1 && $prev == ? (* /)service ]]; then
19211928 _services
1922- [[ -e /etc/mandrake-release ]] && _xinetd_services
1929+ [[ -e /etc/mandrake-release ]] && _comp_compgen_xinetd_services
19231930 else
19241931 local sysvdirs
19251932 _comp_sysvdirs
@@ -1943,10 +1950,11 @@ _comp__init_set_up_service_completions()
19431950}
19441951_comp__init_set_up_service_completions
19451952
1946- # This function completes on modules
1953+ # This function completes on kernel modules
1954+ # @param $1 kernel version
19471955#
1948- # TODO:API: rename per conventions (+ include "kernel" in the name)
1949- _modules ()
1956+ # @since 2.12
1957+ _comp_compgen_kernel_modules ()
19501958{
19511959 local modpath
19521960 modpath=/lib/modules/$1
@@ -1955,12 +1963,13 @@ _modules()
19551963 -e ' s/^\(.*\)\.ko\.zst$/\1/p' ) "
19561964}
19571965
1958- # This function completes on installed modules
1966+ # This function completes on inserted kernel modules
1967+ # @param $1 prefix to filter with, default $cur
19591968#
1960- # TODO:API: rename per conventions (+ include "kernel" in the name)
1961- _installed_modules ()
1969+ # @since 2.12
1970+ _comp_compgen_inserted_kernel_modules ()
19621971{
1963- _comp_compgen -c " $1 " split -- " $( PATH=" $PATH :/sbin" lsmod |
1972+ _comp_compgen -c " ${1 :- $cur } " split -- " $( PATH=" $PATH :/sbin" lsmod |
19641973 awk ' {if (NR != 1) print $1}' ) "
19651974}
19661975
@@ -1971,8 +1980,9 @@ _installed_modules()
19711980#
19721981# @param $1 If -u, only return users/groups the user has access to in
19731982# context of current completion.
1974- # TODO:API: rename per conventions
1975- _usergroup ()
1983+ #
1984+ # @since 2.12
1985+ _comp_compgen_usergroup ()
19761986{
19771987 if [[ $cur == * \\\\ * || $cur == * :* :* ]]; then
19781988 # Give up early on if something seems horribly wrong.
@@ -1986,7 +1996,7 @@ _usergroup()
19861996 prefix=${prefix// \\ / }
19871997 local mycur=${cur#* [:]}
19881998 if [[ ${1-} == -u ]]; then
1989- _allowed_groups " $mycur "
1999+ _comp_compgen -c " $mycur " allowed_groups
19902000 else
19912001 _comp_compgen -c " $mycur " -- -g
19922002 fi
@@ -1998,7 +2008,7 @@ _usergroup()
19982008 # and only replace the 'gr' part
19992009 local mycur=${cur#*: }
20002010 if [[ ${1-} == -u ]]; then
2001- _allowed_groups " $mycur "
2011+ _comp_compgen -c " $mycur " allowed_groups
20022012 else
20032013 _comp_compgen -c " $mycur " -- -g
20042014 fi
@@ -2009,32 +2019,30 @@ _usergroup()
20092019 # slash. It's better to complete into 'chown username ' than 'chown
20102020 # username\:'.
20112021 if [[ ${1-} == -u ]]; then
2012- _allowed_users " $cur "
2022+ _comp_compgen_allowed_users
20132023 else
20142024 _comp_compgen -- -u
20152025 fi
20162026 fi
20172027}
20182028
2019- # TODO:API: rename per conventions
2020- _allowed_users ()
2029+ # @since 2.12
2030+ _comp_compgen_allowed_users ()
20212031{
2022- if _complete_as_root ; then
2023- _comp_compgen -c " ${1 :- $cur } " - - -u
2032+ if _comp_as_root ; then
2033+ _comp_compgen -- -u
20242034 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) "
20272036 fi
20282037}
20292038
2030- # TODO:API: rename per conventions
2031- _allowed_groups ()
2039+ # @since 2.12
2040+ _comp_compgen_allowed_groups ()
20322041{
2033- if _complete_as_root ; then
2034- _comp_compgen -c " $1 " - - -g
2042+ if _comp_as_root ; then
2043+ _comp_compgen -- -g
20352044 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) "
20382046 fi
20392047}
20402048
@@ -2059,8 +2067,8 @@ _shells()
20592067
20602068# This function completes on valid filesystem types
20612069#
2062- # TODO:API: rename per conventions
2063- _fstypes ()
2070+ # @since 2.12
2071+ _comp_compgen_fstypes ()
20642072{
20652073 local fss
20662074
@@ -2078,7 +2086,7 @@ _fstypes()
20782086 $( [[ -d /etc/fs ]] && command ls /etc/fs) "
20792087 fi
20802088
2081- [[ $fss ]] && _comp_compgen -a - - -W " $fss "
2089+ [[ $fss ]] && _comp_compgen -- -W " $fss "
20822090}
20832091
20842092# Get absolute path to a file, with rudimentary canonicalization.
@@ -2164,38 +2172,40 @@ _count_args()
21642172
21652173# This function completes on PCI IDs
21662174#
2167- # TODO:API: rename per conventions
2168- _pci_ids ()
2175+ # @since 2.12
2176+ _comp_compgen_pci_ids ()
21692177{
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}' ) "
21722179}
21732180
21742181# This function completes on USB IDs
21752182#
2176- # TODO:API: rename per conventions
2177- _usb_ids ()
2183+ # @since 2.12
2184+ _comp_compgen_usb_ids ()
21782185{
2179- _comp_compgen -a split -- " $( PATH=" $PATH :/sbin" lsusb | awk ' {print $6}' ) "
2186+ _comp_compgen_split -- " $( PATH=" $PATH :/sbin" lsusb | awk ' {print $6}' ) "
21802187}
21812188
21822189# CD device names
2183- # TODO:API: rename per conventions
2184- _cd_devices ()
2190+ #
2191+ # @since 2.12
2192+ _comp_compgen_cd_devices ()
21852193{
2186- _comp_compgen -ac " ${cur:-/ dev/ } " -- -f -d -X " !*/?([amrs])cd*"
2194+ _comp_compgen -c " ${cur:-/ dev/ } " -- -f -d -X " !*/?([amrs])cd*"
21872195}
21882196
21892197# DVD device names
2190- # TODO:API: rename per conventions
2191- _dvd_devices ()
2198+ #
2199+ # @since 2.12
2200+ _comp_compgen_dvd_devices ()
21922201{
2193- _comp_compgen -ac " ${cur:-/ dev/ } " -- -f -d -X " !*/?(r)dvd*"
2202+ _comp_compgen -c " ${cur:-/ dev/ } " -- -f -d -X " !*/?(r)dvd*"
21942203}
21952204
21962205# TERM environment variable values
2197- # TODO:API: rename per conventions
2198- _terms ()
2206+ #
2207+ # @since 2.12
2208+ _comp_compgen_terms ()
21992209{
22002210 _comp_compgen -a split -- " $( {
22012211 command sed -ne ' s/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap
@@ -2724,8 +2734,9 @@ _comp_root_command()
27242734complete -F _comp_root_command fakeroot gksu gksudo kdesudo really
27252735
27262736# 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 ()
27292740{
27302741 [[ $EUID -eq 0 || ${root_command-} ]]
27312742}
0 commit comments