Skip to content

Commit 37fa70e

Browse files
authored
Merge pull request #1572 from akinomyoga/sed-4
2 parents 137d346 + f6fee8a commit 37fa70e

File tree

11 files changed

+47
-34
lines changed

11 files changed

+47
-34
lines changed

bash_completion

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,12 +2072,12 @@ if [[ $OSTYPE == *@(solaris|aix)* ]]; then
20722072
# This function completes on process IDs.
20732073
_comp_compgen_pids()
20742074
{
2075-
_comp_compgen_split -- "$(command ps -efo pid | tail -n +2)"
2075+
_comp_compgen_split -- "$(command ps -efo pid | _comp_tail -n +2)"
20762076
}
20772077

20782078
_comp_compgen_pgids()
20792079
{
2080-
_comp_compgen_split -- "$(command ps -efo pgid | tail -n +2)"
2080+
_comp_compgen_split -- "$(command ps -efo pgid | _comp_tail -n +2)"
20812081
}
20822082
_comp_compgen_pnames()
20832083
{
@@ -2098,7 +2098,7 @@ else
20982098
{
20992099
local -a procs=()
21002100
if [[ ${1-} == -s ]]; then
2101-
_comp_split procs "$(command ps ax -o comm | tail -n +2)"
2101+
_comp_split procs "$(command ps ax -o comm | _comp_tail -n +2)"
21022102
else
21032103
# Some versions of ps don't support "command", but do "comm", e.g.
21042104
# some busybox ones. Fall back
@@ -3560,20 +3560,33 @@ _comp_xfunc()
35603560
"$xfunc_name" "${@:3}"
35613561
}
35623562
3563-
# Call a POSIX-compatible awk. Solaris awk is not POSIX-compliant, but Solaris
3564-
# provides a POSIX-compatible version through /usr/xpg4/bin/awk. We switch the
3565-
# implementation to /usr/xpg4/bin/awk in Solaris if any.
3563+
# Call a POSIX-compatible awk and tail. Solaris awk and tail are not
3564+
# POSIX-compliant, but Solaris provides POSIX-compatible versions through
3565+
# /usr/xpg4/bin/{awk,tail}. We switch the implementation to
3566+
# /usr/xpg4/bin/{awk,tail} in Solaris if any.
35663567
# @since 2.12
3567-
if [[ $OSTYPE == *solaris* && -x /usr/xpg4/bin/awk ]]; then
3568-
_comp_awk()
3569-
{
3570-
/usr/xpg4/bin/awk "$@"
3571-
}
3572-
else
3573-
_comp_awk()
3574-
{
3575-
command awk "$@"
3576-
}
3568+
_comp_awk()
3569+
{
3570+
command awk "$@"
3571+
}
3572+
# @since 2.18
3573+
_comp_tail()
3574+
{
3575+
command tail "$@"
3576+
}
3577+
if [[ $OSTYPE == *solaris* ]]; then
3578+
if [[ -x /usr/xpg4/bin/awk ]]; then
3579+
_comp_awk()
3580+
{
3581+
/usr/xpg4/bin/awk "$@"
3582+
}
3583+
fi
3584+
if [[ -x /usr/xpg4/bin/tail ]]; then
3585+
_comp_tail()
3586+
{
3587+
/usr/xpg4/bin/tail "$@"
3588+
}
3589+
fi
35773590
fi
35783591
35793592
# List custom/extra completion files to source on the startup

completions-core/2to3.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _comp_cmd_2to3()
1111
;;
1212
-f | --fix | -x | --nofix)
1313
_comp_compgen_split -- "$(
14-
"$1" --list-fixes 2>/dev/null | tail -n +2
14+
"$1" --list-fixes 2>/dev/null | _comp_tail -n +2
1515
)"
1616
return
1717
;;

completions-core/7z.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ _comp_cmd_7z()
9999
if [[ ${words[1]} == d ]]; then
100100
_comp_compgen_split -l -- "$(
101101
"$1" l "${words[2]}" -slt 2>/dev/null | command sed -n \
102-
's/^Path = \(.*\)$/\1/p' 2>/dev/null | tail -n+2
102+
's/^Path = \(.*\)$/\1/p' 2>/dev/null | _comp_tail -n +2
103103
)"
104104
compopt -o filenames
105105
else

completions-core/cowsay.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ _comp_cmd_cowsay()
77

88
case $prev in
99
-f)
10-
_comp_compgen_split -- "$(cowsay -l 2>/dev/null | tail -n +2)"
10+
_comp_compgen_split -- "$(cowsay -l 2>/dev/null | _comp_tail -n +2)"
1111
return
1212
;;
1313
esac

completions-core/function.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _comp_cmd_function()
88
if ((cword == 1)); then
99
_comp_compgen -- -A function
1010
else
11-
local funcdef=$(type -- "${words[1]}" 2>/dev/null | tail -n +3)
11+
local funcdef=$(type -- "${words[1]}" 2>/dev/null | _comp_tail -n +3)
1212
COMPREPLY=("()${funcdef:+ $funcdef}")
1313
fi
1414
} &&

completions-core/genisoimage.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ _comp_cmd_mkisofs()
1313
;;
1414
-*-charset)
1515
_comp_compgen_split -- "$(mkisofs -input-charset help 2>&1 |
16-
tail -n +3)"
16+
_comp_tail -n +3)"
1717
return
1818
;;
1919
-uid)

completions-core/mcrypt.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _comp_cmd_mcrypt()
2626
;;
2727
-h | --hash)
2828
_comp_compgen_split -- "$("$1" --list-hash 2>/dev/null |
29-
tail -n +2)"
29+
_comp_tail -n +2)"
3030
return
3131
;;
3232
-k | -s | --key | --keysize)

completions-core/msynctool.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ _comp_cmd_msynctool()
1212
return
1313
;;
1414
--addmember)
15-
_comp_compgen_split -- "$("$1" --listplugins | tail -n +2)"
15+
_comp_compgen_split -- "$("$1" --listplugins | _comp_tail -n +2)"
1616
return
1717
;;
1818
esac
1919

2020
case $prev in
2121
--configure | --addgroup | --delgroup | --showgroup | --sync | --addmember)
22-
_comp_compgen_split -- "$("$1" --listgroups | tail -n +2)"
22+
_comp_compgen_split -- "$("$1" --listgroups | _comp_tail -n +2)"
2323
return
2424
;;
2525
--showformats | --filter-objtype | --slow-sync)
26-
_comp_compgen_split -- "$("$1" --listobjects | tail -n +2)"
26+
_comp_compgen_split -- "$("$1" --listobjects | _comp_tail -n +2)"
2727
return
2828
;;
2929
esac

completions-core/pdftotext.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _comp_cmd_pdftotext()
1111
return
1212
;;
1313
-enc)
14-
_comp_compgen_split -- "$("$1" -listenc 2>/dev/null | tail -n +2)"
14+
_comp_compgen_split -- "$("$1" -listenc 2>/dev/null | _comp_tail -n +2)"
1515
return
1616
;;
1717
-eol)

completions-fallback/nmcli.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
_comp_cmd_nmcli__con_id()
77
{
88
_comp_compgen_split -l -- "$(nmcli con list 2>/dev/null |
9-
tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')"
9+
_comp_awk -F ' {2,}' 'NR >= 2 {print $1}')"
1010
}
1111

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

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

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

3030
_comp_cmd_nmcli()

0 commit comments

Comments
 (0)