Skip to content
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
45 changes: 29 additions & 16 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -2072,12 +2072,12 @@ if [[ $OSTYPE == *@(solaris|aix)* ]]; then
# This function completes on process IDs.
_comp_compgen_pids()
{
_comp_compgen_split -- "$(command ps -efo pid | tail -n +2)"
_comp_compgen_split -- "$(command ps -efo pid | _comp_tail -n +2)"
}

_comp_compgen_pgids()
{
_comp_compgen_split -- "$(command ps -efo pgid | tail -n +2)"
_comp_compgen_split -- "$(command ps -efo pgid | _comp_tail -n +2)"
}
_comp_compgen_pnames()
{
Expand All @@ -2098,7 +2098,7 @@ else
{
local -a procs=()
if [[ ${1-} == -s ]]; then
_comp_split procs "$(command ps ax -o comm | tail -n +2)"
_comp_split procs "$(command ps ax -o comm | _comp_tail -n +2)"
else
# Some versions of ps don't support "command", but do "comm", e.g.
# some busybox ones. Fall back
Expand Down Expand Up @@ -3560,20 +3560,33 @@ _comp_xfunc()
"$xfunc_name" "${@:3}"
}

# Call a POSIX-compatible awk. Solaris awk is not POSIX-compliant, but Solaris
# provides a POSIX-compatible version through /usr/xpg4/bin/awk. We switch the
# implementation to /usr/xpg4/bin/awk in Solaris if any.
# Call a POSIX-compatible awk and tail. Solaris awk and tail are not
# POSIX-compliant, but Solaris provides POSIX-compatible versions through
# /usr/xpg4/bin/{awk,tail}. We switch the implementation to
# /usr/xpg4/bin/{awk,tail} in Solaris if any.
# @since 2.12
if [[ $OSTYPE == *solaris* && -x /usr/xpg4/bin/awk ]]; then
_comp_awk()
{
/usr/xpg4/bin/awk "$@"
}
else
_comp_awk()
{
command awk "$@"
}
_comp_awk()
{
command awk "$@"
}
# @since 2.18
_comp_tail()
{
command tail "$@"
}
if [[ $OSTYPE == *solaris* ]]; then
if [[ -x /usr/xpg4/bin/awk ]]; then
_comp_awk()
{
/usr/xpg4/bin/awk "$@"
}
fi
if [[ -x /usr/xpg4/bin/tail ]]; then
_comp_tail()
{
/usr/xpg4/bin/tail "$@"
}
fi
fi

# List custom/extra completion files to source on the startup
Expand Down
2 changes: 1 addition & 1 deletion completions-core/2to3.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _comp_cmd_2to3()
;;
-f | --fix | -x | --nofix)
_comp_compgen_split -- "$(
"$1" --list-fixes 2>/dev/null | tail -n +2
"$1" --list-fixes 2>/dev/null | _comp_tail -n +2
)"
return
;;
Expand Down
2 changes: 1 addition & 1 deletion completions-core/7z.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ _comp_cmd_7z()
if [[ ${words[1]} == d ]]; then
_comp_compgen_split -l -- "$(
"$1" l "${words[2]}" -slt 2>/dev/null | command sed -n \
's/^Path = \(.*\)$/\1/p' 2>/dev/null | tail -n+2
's/^Path = \(.*\)$/\1/p' 2>/dev/null | _comp_tail -n +2
)"
compopt -o filenames
else
Expand Down
2 changes: 1 addition & 1 deletion completions-core/cowsay.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _comp_cmd_cowsay()

case $prev in
-f)
_comp_compgen_split -- "$(cowsay -l 2>/dev/null | tail -n +2)"
_comp_compgen_split -- "$(cowsay -l 2>/dev/null | _comp_tail -n +2)"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions-core/function.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _comp_cmd_function()
if ((cword == 1)); then
_comp_compgen -- -A function
else
local funcdef=$(type -- "${words[1]}" 2>/dev/null | tail -n +3)
local funcdef=$(type -- "${words[1]}" 2>/dev/null | _comp_tail -n +3)
COMPREPLY=("()${funcdef:+ $funcdef}")
fi
} &&
Expand Down
2 changes: 1 addition & 1 deletion completions-core/genisoimage.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _comp_cmd_mkisofs()
;;
-*-charset)
_comp_compgen_split -- "$(mkisofs -input-charset help 2>&1 |
tail -n +3)"
_comp_tail -n +3)"
return
;;
-uid)
Expand Down
2 changes: 1 addition & 1 deletion completions-core/mcrypt.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _comp_cmd_mcrypt()
;;
-h | --hash)
_comp_compgen_split -- "$("$1" --list-hash 2>/dev/null |
tail -n +2)"
_comp_tail -n +2)"
return
;;
-k | -s | --key | --keysize)
Expand Down
6 changes: 3 additions & 3 deletions completions-core/msynctool.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ _comp_cmd_msynctool()
return
;;
--addmember)
_comp_compgen_split -- "$("$1" --listplugins | tail -n +2)"
_comp_compgen_split -- "$("$1" --listplugins | _comp_tail -n +2)"
return
;;
esac

case $prev in
--configure | --addgroup | --delgroup | --showgroup | --sync | --addmember)
_comp_compgen_split -- "$("$1" --listgroups | tail -n +2)"
_comp_compgen_split -- "$("$1" --listgroups | _comp_tail -n +2)"
return
;;
--showformats | --filter-objtype | --slow-sync)
_comp_compgen_split -- "$("$1" --listobjects | tail -n +2)"
_comp_compgen_split -- "$("$1" --listobjects | _comp_tail -n +2)"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions-core/pdftotext.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _comp_cmd_pdftotext()
return
;;
-enc)
_comp_compgen_split -- "$("$1" -listenc 2>/dev/null | tail -n +2)"
_comp_compgen_split -- "$("$1" -listenc 2>/dev/null | _comp_tail -n +2)"
return
;;
-eol)
Expand Down
8 changes: 4 additions & 4 deletions completions-fallback/nmcli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
_comp_cmd_nmcli__con_id()
{
_comp_compgen_split -l -- "$(nmcli con list 2>/dev/null |
tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')"
_comp_awk -F ' {2,}' 'NR >= 2 {print $1}')"
}

_comp_cmd_nmcli__con_uuid()
{
_comp_compgen_split -- "$(nmcli con list 2>/dev/null |
tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')"
_comp_awk -F ' {2,}' 'NR >= 2 {print $2}')"
}

_comp_cmd_nmcli__ap_ssid()
{
_comp_compgen_split -l -- "$(nmcli dev wifi list 2>/dev/null |
tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')"
_comp_awk -F ' {2,}' 'NR >= 2 {print $1}')"
}

_comp_cmd_nmcli__ap_bssid()
{
_comp_compgen_split -- "$(nmcli dev wifi list 2>/dev/null |
tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')"
_comp_awk -F ' {2,}' 'NR >= 2 {print $2}')"
}

_comp_cmd_nmcli()
Expand Down