Skip to content

Commit

Permalink
style: use command to call awk
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Nov 27, 2023
1 parent 63dbf2b commit 65ea699
Show file tree
Hide file tree
Showing 72 changed files with 133 additions and 133 deletions.
34 changes: 17 additions & 17 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ _comp_compgen_available_interfaces()
else
ifconfig -a || ip -c=never link show || ip link show
fi
} 2>/dev/null | awk \
} 2>/dev/null | command awk \
'/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')" &&
_comp_compgen -U generated set "${generated[@]}"
}
Expand Down Expand Up @@ -1943,7 +1943,7 @@ _comp_compgen_services()
systemctl list-units --full --all ||
systemctl list-unit-files
} 2>/dev/null |
awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')
command awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')
_comp_split -la services "$_generated"

if [[ -x /sbin/upstart-udev-bridge ]]; then
Expand Down Expand Up @@ -2016,7 +2016,7 @@ _comp_compgen_kernel_modules()
_comp_compgen_inserted_kernel_modules()
{
_comp_compgen -c "${1:-$cur}" split -- "$(PATH="$PATH:/sbin" lsmod |
awk '{if (NR != 1) print $1}')"
command awk '{if (NR != 1) print $1}')"
}

# This function completes on user or user:group format; as for chown and cpio.
Expand Down Expand Up @@ -2097,7 +2097,7 @@ _comp_compgen_allowed_groups()
_comp_compgen_selinux_users()
{
_comp_compgen_split -- "$(semanage user -nl 2>/dev/null |
awk '{ print $1 }')"
command awk '{ print $1 }')"
}

# This function completes on valid shells
Expand All @@ -2124,14 +2124,14 @@ _comp_compgen_fstypes()
if [[ -e /proc/filesystems ]]; then
# Linux
_fss="$(cut -d$'\t' -f2 /proc/filesystems)
$(awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null)"
$(command awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null)"
else
# Generic
_fss="$(awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null)
$(awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null)
$(awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null)
$(awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null)
$(lsvfs 2>/dev/null | awk '$1 !~ /^(Filesystem|[^a-zA-Z])/ { print $1 }')
_fss="$(command awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null)
$(command awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null)
$(command awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null)
$(command awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null)
$(lsvfs 2>/dev/null | command awk '$1 !~ /^(Filesystem|[^a-zA-Z])/ { print $1 }')
$([[ -d /etc/fs ]] && command ls /etc/fs)"
fi

Expand Down Expand Up @@ -2289,15 +2289,15 @@ _comp_count_args()
# @since 2.12
_comp_compgen_pci_ids()
{
_comp_compgen_split -- "$(PATH="$PATH:/sbin" lspci -n | awk '{print $3}')"
_comp_compgen_split -- "$(PATH="$PATH:/sbin" lspci -n | command awk '{print $3}')"
}

# This function completes on USB IDs
#
# @since 2.12
_comp_compgen_usb_ids()
{
_comp_compgen_split -- "$(PATH="$PATH:/sbin" lsusb | awk '{print $6}')"
_comp_compgen_split -- "$(PATH="$PATH:/sbin" lsusb | command awk '{print $6}')"
}

# CD device names
Expand Down Expand Up @@ -2325,11 +2325,11 @@ _comp_compgen_terms()
command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap
{
toe -a || toe
} | awk '{ print $1 }'
} | command awk '{ print $1 }'
_comp_expand_glob dirs '/{etc,lib,usr/lib,usr/share}/terminfo/?'
((${#dirs[@]})) &&
find "${dirs[@]}" -type f -maxdepth 1 |
awk -F/ '{ print $NF }'
command awk -F/ '{ print $NF }'
} 2>/dev/null)"
}

Expand Down Expand Up @@ -2533,7 +2533,7 @@ _comp_compgen_known_hosts__impl()
# TODO(?): try to make known hosts files with more than one consecutive
# spaces in their name work (watch out for ~ expansion
# breakage! Alioth#311595)
if _comp_split -l tmpkh "$(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t=]+", "") { print $0 }' "${config[@]}" | sort -u)"; then
if _comp_split -l tmpkh "$(command awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t=]+", "") { print $0 }' "${config[@]}" | sort -u)"; then
local tmpkh2 j ret
for i in "${tmpkh[@]}"; do
# First deal with quoted entries...
Expand Down Expand Up @@ -2628,15 +2628,15 @@ _comp_compgen_known_hosts__impl()
type avahi-browse &>/dev/null; then
# Some old versions of avahi-browse reportedly didn't have -k
# (even if mentioned in the manpage); those we do not support any more.
local generated=$(avahi-browse -cprak 2>/dev/null | awk -F';' \
local generated=$(avahi-browse -cprak 2>/dev/null | command awk -F';' \
'/^=/ && $5 ~ /^_(ssh|workstation)\._tcp$/ { print $7 }' |
sort -u)
_comp_compgen -av known_hosts -- -P "$prefix" -S "$suffix" -W '$generated'
fi

# Add hosts reported by ruptime.
if type ruptime &>/dev/null; then
local generated=$(ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }')
local generated=$(ruptime 2>/dev/null | command awk '!/^ruptime:/ { print $1 }')
_comp_compgen -av known_hosts -- -W '$generated'
fi

Expand Down
2 changes: 1 addition & 1 deletion completions/_adb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _comp_cmd_adb()
_comp_compgen -av tmp help -- help
fi
if [[ ! $cur || $cur != -* ]]; then
tmp+=($("$1" help 2>&1 | awk '$1 == "adb" { print $2 }'))
tmp+=($("$1" help 2>&1 | command awk '$1 == "adb" { print $2 }'))
tmp+=(devices connect disconnect sideload)
fi
((${#tmp[@]})) &&
Expand Down
2 changes: 1 addition & 1 deletion completions/_modules
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ _comp_cmd_module()

local options
options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' |
awk '{print $2}' | command sed -e 's/|/ /g' | sort)"
command awk '{print $2}' | command sed -e 's/|/ /g' | sort)"

_comp_compgen -- -W "$options"

Expand Down
8 changes: 4 additions & 4 deletions completions/_mount
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _comp_cmd_mount()
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[[ -x $sm ]] || continue
_comp_compgen -c "${cur#*:}" split -- "$(
"$sm" -e ${cur%%:*} | awk 'NR>1 {print $1}'
"$sm" -e ${cur%%:*} | command awk 'NR>1 {print $1}'
)"
return
done
Expand All @@ -53,17 +53,17 @@ _comp_cmd_mount()
elif [[ -r /etc/vfstab ]]; then
# Solaris
_comp_compgen_split -- "$(
awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab
command awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab
)"
elif [[ ! -e /etc/fstab ]]; then
# probably Cygwin
_comp_compgen_split -- "$(
"$1" | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}'
"$1" | command awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}'
)"
else
# probably BSD
_comp_compgen_split -- "$(
awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab
command awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab
)"
fi
} &&
Expand Down
2 changes: 1 addition & 1 deletion completions/_mount.linux
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ _comp_cmd_mount()
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[[ -x $sm ]] || continue
_comp_compgen -c "${cur#*:}" split -- "$(
"$sm" -e ${cur%%:*} | awk 'NR>1 {print $1}'
"$sm" -e ${cur%%:*} | command awk 'NR>1 {print $1}'
)"
return
done
Expand Down
2 changes: 1 addition & 1 deletion completions/_rfkill
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _comp_cmd_rfkill()
2)
if [[ $prev == block || $prev == unblock ]]; then
_comp_compgen_split -- "$("$1" list |
awk -F: '/^[0-9]/ {print $1}') all wifi bluetooth uwb
command awk -F: '/^[0-9]/ {print $1}') all wifi bluetooth uwb
wimax wwan gps"
fi
;;
Expand Down
2 changes: 1 addition & 1 deletion completions/_udevadm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ _comp_cmd_udevadm()
;;
*)
_comp_compgen_split -- "$("$1" --help 2>/dev/null |
awk '/^[ \t]/ { print $1 }')"
command awk '/^[ \t]/ { print $1 }')"
;;
esac
return
Expand Down
6 changes: 3 additions & 3 deletions completions/_xm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
_comp_cmd_xm__domain_names()
{
_comp_compgen_split -- "$(xm list 2>/dev/null |
awk '!/Name|Domain-0/ { print $1 }')"
command awk '!/Name|Domain-0/ { print $1 }')"
}

_comp_cmd_xm()
Expand Down Expand Up @@ -147,7 +147,7 @@ _comp_cmd_xm()
;;
3)
_comp_compgen_split -- "$(xm block-list "$prev" \
2>/dev/null | awk '!/Vdev/ { print $1 }')"
2>/dev/null | command awk '!/Vdev/ { print $1 }')"
;;
esac
;;
Expand All @@ -171,7 +171,7 @@ _comp_cmd_xm()
;;
3)
_comp_compgen_split -- "$(xm network-list "$prev" \
2>/dev/null | awk '!/Idx/ { print $1 }')"
2>/dev/null | command awk '!/Idx/ { print $1 }')"
;;
esac
;;
Expand Down
2 changes: 1 addition & 1 deletion completions/apache2ctl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _comp_cmd_apache2ctl()
_comp_initialize -- "$@" || return

local APWORDS
APWORDS=$("$1" 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' |
APWORDS=$("$1" 2>&1 >/dev/null | command awk 'NR<2 { print $3; exit }' |
tr "|" " ")

_comp_compgen -- -W "$APWORDS"
Expand Down
2 changes: 1 addition & 1 deletion completions/apt-cache
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _comp_xfunc_apt_cache_compgen_sources()
_comp_cmd_apt_cache__compgen_sources()
{
_comp_compgen_split -- "$("$1" dumpavail |
awk '$1 == "Source:" { print $2 }' | sort -u)"
command awk '$1 == "Source:" { print $2 }' | sort -u)"
}

# List APT binary packages
Expand Down
2 changes: 1 addition & 1 deletion completions/apt-get
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _comp_cmd_apt_get()
pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_compgen -x apt-cache packages
_comp_compgen -a split -- "$(apt-cache dumpavail |
awk '$1 == "Source:" { print $2 }' | sort -u)"
command awk '$1 == "Source:" { print $2 }' | sort -u)"
;;
install | reinstall)
if _comp_looks_like_path "$cur"; then
Expand Down
4 changes: 2 additions & 2 deletions completions/aspell
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ _comp_cmd_aspell()
;;
--mode)
_comp_compgen_split -- "$("$1" modes 2>/dev/null |
awk '{ print $1 }')"
command awk '{ print $1 }')"
return
;;
--sug-mode)
Expand All @@ -53,7 +53,7 @@ _comp_cmd_aspell()
;;
--add-filter | --rem-filter)
_comp_compgen_split -- "$("$1" filters 2>/dev/null |
awk '{ print $1 }')"
command awk '{ print $1 }')"
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/bk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _comp_cmd_bk()
_comp_initialize -- "$@" || return

local BKCMDS="$(bk help topics 2>/dev/null |
awk '/^ bk/ { print $2 }' | xargs printf '%s ')"
command awk '/^ bk/ { print $2 }' | xargs printf '%s ')"

_comp_compgen -- -W "$BKCMDS"
_comp_compgen -a filedir
Expand Down
2 changes: 1 addition & 1 deletion completions/brctl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _comp_cmd_brctl()

*)
_comp_compgen_split -- "$("$1" show |
awk 'NR>1 {print $1}')"
command awk 'NR>1 {print $1}')"
;;
esac
;;
Expand Down
2 changes: 1 addition & 1 deletion completions/ccache
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _comp_cmd_ccache()
--set-config | -${noargopts}o)
if [[ $cur != *=* ]]; then
_comp_compgen_split -S = -- "$("$1" -p 2>/dev/null |
awk '$3 = "=" { print $2 }')"
command awk '$3 = "=" { print $2 }')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
return
Expand Down
4 changes: 2 additions & 2 deletions completions/chronyc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _comp_cmd_chronyc__command_args()
{
local -a args
_comp_split args "$("$1" help 2>/dev/null |
awk '/^'"$prev"'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')"
command awk '/^'"$prev"'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')"
case $args in
\<address\>) _comp_compgen_known_hosts -- "$cur" ;;
\<*) ;;
Expand Down Expand Up @@ -43,7 +43,7 @@ _comp_cmd_chronyc()
case $args in
0)
_comp_compgen_split -- "$("$1" help 2>/dev/null |
awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')"
command awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')"
;;
1)
_comp_cmd_chronyc__command_args "$1"
Expand Down
2 changes: 1 addition & 1 deletion completions/configure
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _comp_cmd_configure()
# the form --option=SETTING will include 'SETTING' as a contextual hint
if [[ ${BASH_COMPLETION_CMD_CONFIGURE_HINTS-${COMP_CONFIGURE_HINTS-}} ]]; then
_comp_compgen_split -- "$("$1" --help 2>&1 |
awk '/^ --[A-Za-z]/ { print $1; \
command awk '/^ --[A-Za-z]/ { print $1; \
if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g')"
[[ ${COMPREPLY-} == *=* ]] && compopt -o nospace
else
Expand Down
2 changes: 1 addition & 1 deletion completions/cpan2dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _comp_cmd_cpan2dist()
packagelist="$dir/02packages.details.txt.gz"
done
[[ $packagelist ]] && COMPREPLY=($(zgrep "^${cur//-/::}" \
"$packagelist" 2>/dev/null | awk '{print $1}' |
"$packagelist" 2>/dev/null | command awk '{print $1}' |
command sed -e 's/::/-/g'))
fi
} &&
Expand Down
2 changes: 1 addition & 1 deletion completions/curl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ _comp_cmd_curl()
--help | -${noargopts}h)
local x categories=(
$("$1" --help non-existent-category 2>&1 |
awk '/^[[:space:]]/ {print $1}')
command awk '/^[[:space:]]/ {print $1}')
)
if ((${#categories[@]})); then
for x in "${categories[@]}"; do
Expand Down
8 changes: 4 additions & 4 deletions completions/cvs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _comp_cmd_cvs__modules()
_comp_cmd_cvs__compgen_commands()
{
_comp_compgen_split -- "$(
"$1" --help-commands 2>&1 | awk '/^( *|\t)/ { print $1 }'
"$1" --help-commands 2>&1 | command awk '/^( *|\t)/ { print $1 }'
)"
}

Expand All @@ -42,7 +42,7 @@ _comp_xfunc_cvs_compgen_roots()
{
local -a cvsroots=()
[[ -v CVSROOT ]] && cvsroots=("$CVSROOT")
[[ -r ~/.cvspass ]] && cvsroots+=($(awk '{ print $2 }' ~/.cvspass))
[[ -r ~/.cvspass ]] && cvsroots+=($(command awk '{ print $2 }' ~/.cvspass))
[[ -r CVS/Root ]] && mapfile -tO "${#cvsroots[@]}" cvsroots <CVS/Root
((${#cvsroots[@]})) &&
_comp_compgen -U cvsroots -- -W '"${cvsroots[@]}"'
Expand Down Expand Up @@ -237,7 +237,7 @@ _comp_cmd_cvs()
if [[ $cur != -* ]]; then
[[ ! $has_cvsroot ]] && cvsroot=${CVSROOT-}
COMPREPLY=($(cvs -d "$cvsroot" co -c 2>/dev/null |
awk '{print $1}'))
command awk '{print $1}'))
((${#COMPREPLY[@]})) &&
_comp_compgen -- -W '"${COMPREPLY[@]}"'
else
Expand Down Expand Up @@ -321,7 +321,7 @@ _comp_cmd_cvs()

if [[ $cur != -* ]]; then
[[ ! $has_cvsroot ]] && cvsroot=${CVSROOT-}
COMPREPLY=($(cvs -d "$cvsroot" co -c | awk '{print $1}'))
COMPREPLY=($(cvs -d "$cvsroot" co -c | command awk '{print $1}'))
((${#COMPREPLY[@]})) &&
_comp_compgen -- -W '"${COMPREPLY[@]}"'
else
Expand Down
8 changes: 4 additions & 4 deletions completions/cvsps
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ _comp_cmd_cvsps()
;;
-s)
_comp_compgen_split -- "$("$1" 2>/dev/null |
awk '/^PatchSet:?[ \t]/ { print $2 }')"
command awk '/^PatchSet:?[ \t]/ { print $2 }')"
return
;;
-a)
_comp_compgen_split -- "$("$1" 2>/dev/null |
awk '/^Author:[ \t]/ { print $2 }')"
command awk '/^Author:[ \t]/ { print $2 }')"
return
;;
-b)
_comp_compgen_split -- "$("$1" 2>/dev/null |
awk '/^Branch:[ \t]/ { print $2 }')"
command awk '/^Branch:[ \t]/ { print $2 }')"
return
;;
-r)
_comp_compgen_split -- "$("$1" 2>/dev/null |
awk '/^Tag:[ \t]+[^(]/ { print $2 }')"
command awk '/^Tag:[ \t]+[^(]/ { print $2 }')"
return
;;
-p)
Expand Down
Loading

0 comments on commit 65ea699

Please sign in to comment.