Protect grep invocations from user aliases (Alioth: 312143).
This commit is contained in:
parent
247ada3cc4
commit
8caddc47cf
1
CHANGES
1
CHANGES
@ -47,6 +47,7 @@ bash-completion (2.x)
|
||||
* Fix leaking local variables from various completions.
|
||||
* Turn on -o filenames in _filedir on bash >= 4.
|
||||
* Deprecate modules completion, upstream modules >= 3.2.7 ships one.
|
||||
* Protect grep invocations from user aliases (Alioth: 312143).
|
||||
|
||||
[ Freddy Vulto ]
|
||||
* Added _get_pword() helper function, thanks to Sung Pae (Alioth: #312030)
|
||||
|
@ -440,7 +440,7 @@ _split_longopt()
|
||||
_parse_help() {
|
||||
local cmd
|
||||
cmd=$1
|
||||
$cmd --help | grep -- "^[[:space:]]*-" | tr "," " " | \
|
||||
$cmd --help | command grep -- "^[[:space:]]*-" | tr "," " " | \
|
||||
awk '{print $1; if ($2 ~ /-.*/) { print $2 } }' | sed -e "s:=.*::g"
|
||||
}
|
||||
|
||||
@ -706,8 +706,9 @@ _usergroup()
|
||||
#
|
||||
_shells()
|
||||
{
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( grep "^[[:space:]]*/" \
|
||||
/etc/shells 2>/dev/null )' -- "$cur" ) )
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
|
||||
'$( command grep "^[[:space:]]*/" /etc/shells 2>/dev/null )' \
|
||||
-- "$cur" ) )
|
||||
}
|
||||
|
||||
# Get real command.
|
||||
@ -1368,7 +1369,7 @@ _known_hosts_real()
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( \
|
||||
compgen -P "$prefix$user" -S "$suffix" -W \
|
||||
"$( avahi-browse -cpr _workstation._tcp 2>/dev/null | \
|
||||
grep ^= | cut -d\; -f7 | sort -u )" -- "$cur" ) )
|
||||
command grep ^= | cut -d\; -f7 | sort -u )" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
# Add results of normal hostname completion, unless
|
||||
|
@ -37,7 +37,7 @@ _module_avail ()
|
||||
{
|
||||
local modules="$( \
|
||||
module avail 2>&1 | \
|
||||
grep -E -v '^(-|$)' | \
|
||||
command grep -E -v '^(-|$)' | \
|
||||
xargs printf '%s\n' | sed -e 's/(default)//g' | sort )"
|
||||
|
||||
compgen -W "$modules" -- $1
|
||||
@ -55,7 +55,7 @@ _module ()
|
||||
if [ $COMP_CWORD -eq 1 ] ; then
|
||||
# First parameter on line -- we expect it to be a mode selection
|
||||
|
||||
options="$( module help 2>&1 | grep -E '^[[:space:]]*\+' | \
|
||||
options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \
|
||||
awk '{print $2}' | sed -e 's/|/ /g' | sort )"
|
||||
|
||||
COMPREPLY=( $(compgen -W "$options" -- "$cur") )
|
||||
|
@ -42,7 +42,7 @@ _apt_get()
|
||||
;;
|
||||
-t|--target-release|--default-release)
|
||||
COMPREPLY=( $( apt-cache policy | \
|
||||
grep "release.o=Debian,a=$cur" | \
|
||||
command grep "release.o=Debian,a=$cur" | \
|
||||
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
|
||||
return 0
|
||||
;;
|
||||
@ -98,7 +98,7 @@ _apt_cache()
|
||||
|
||||
showsrc)
|
||||
COMPREPLY=( $( apt-cache dumpavail | \
|
||||
grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
|
||||
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
|
@ -9,7 +9,8 @@ _comp_dpkg_hold_packages()
|
||||
} || {
|
||||
_comp_dpkg_hold_packages()
|
||||
{
|
||||
grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" | cut -d\ -f2
|
||||
command grep -B 2 'hold' /var/lib/dpkg/status | \
|
||||
command grep "Package: $1" | cut -d\ -f2
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ _aptitude()
|
||||
;;
|
||||
-t|--target-release|--default-release)
|
||||
COMPREPLY=( $( apt-cache policy | \
|
||||
grep "release.o=Debian,a=$cur" | \
|
||||
command grep "release.o=Debian,a=$cur" | \
|
||||
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ) )
|
||||
return 0
|
||||
;;
|
||||
|
@ -7,7 +7,8 @@ _bk() {
|
||||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
BKCMDS="$( bk help topics | grep '^ bk' | cut -d ' ' -f 4 | xargs echo )"
|
||||
BKCMDS="$( bk help topics | command grep '^ bk' | cut -d ' ' -f 4 | \
|
||||
xargs echo )"
|
||||
|
||||
COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) )
|
||||
_filedir
|
||||
|
@ -72,7 +72,7 @@ _cfrun()
|
||||
done
|
||||
[ ! -f $hostfile ] && return 0
|
||||
|
||||
COMPREPLY=( $(compgen -W "$( grep -v \
|
||||
COMPREPLY=( $(compgen -W "$( command grep -v \
|
||||
-E '(=|^$|^#)' $hostfile )" -- "$cur" ) )
|
||||
fi
|
||||
;;
|
||||
|
@ -8,11 +8,11 @@ _comp_dpkg_installed_packages()
|
||||
} || {
|
||||
_comp_dpkg_installed_packages()
|
||||
{
|
||||
grep -A 1 "Package: $1" /var/lib/dpkg/status | \
|
||||
grep -B 1 -Ee "ok installed|half-installed|unpacked| \
|
||||
command grep -A 1 "Package: $1" /var/lib/dpkg/status | \
|
||||
command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
|
||||
half-configured|config-files" \
|
||||
-Ee "^Essential: yes" | \
|
||||
grep "Package: $1" | cut -d\ -f2
|
||||
command grep "Package: $1" | cut -d\ -f2
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ _isql()
|
||||
cur=`_get_cword`
|
||||
|
||||
[ -f "$ODBCINI" ] \
|
||||
&& COMPREPLY=( $( grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) )
|
||||
&& COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) )
|
||||
} &&
|
||||
complete -F _isql isql
|
||||
|
||||
|
@ -64,10 +64,10 @@ _java_classes()
|
||||
if type zipinfo &>/dev/null; then
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
|
||||
"$i" "$cur*" 2>/dev/null | \
|
||||
grep '^[^$]*\.class$' ) )
|
||||
command grep '^[^$]*\.class$' ) )
|
||||
else
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( jar tf "$i" \
|
||||
"$cur" | grep '^[^$]*\.class$' ) )
|
||||
"$cur" | command grep '^[^$]*\.class$' ) )
|
||||
fi
|
||||
|
||||
elif [ -d $i ]; then
|
||||
@ -76,7 +76,7 @@ _java_classes()
|
||||
# See Debian bug #496828
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( find "$i" -type f \
|
||||
-maxdepth 1 -path "$i/$cur*.class" 2>/dev/null | \
|
||||
grep -v "\\$" | sed -e "s|^$i/||" ) )
|
||||
command grep -v "\\$" | sed -e "s|^$i/||" ) )
|
||||
|
||||
# FIXME: if we have foo.class and foo/, the completion
|
||||
# returns "foo/"... how to give precedence to files
|
||||
@ -108,7 +108,7 @@ _java_packages()
|
||||
fi
|
||||
done
|
||||
# keep only packages
|
||||
COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | grep "/$" ) )
|
||||
COMPREPLY=( $( tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$" ) )
|
||||
# remove packages extension
|
||||
COMPREPLY=( ${COMPREPLY[@]%/} )
|
||||
# convert path syntax to package syntax
|
||||
|
@ -112,7 +112,7 @@ _perldoc()
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
|
||||
'$( PAGER=/bin/cat man perl | \
|
||||
sed -ne "/perl.*Perl overview/,/perlwin32/p" | \
|
||||
awk "\$NF=2 { print \$1}" | grep perl )' -- "$cur" ) )
|
||||
awk "\$NF=2 { print \$1}" | command grep perl )' -- "$cur" ) )
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ _portinstall()
|
||||
|
||||
[[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
|
||||
|
||||
COMPREPLY=( $( grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
|
||||
COMPREPLY2=( $( grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
|
||||
COMPREPLY=( $( command grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
|
||||
COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
|
||||
cut -d'|' -f2 ) )
|
||||
COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
|
||||
COMPREPLY=( "${COMPREPLY[@]}" "${COMPREPLY2[@]}" )
|
||||
|
@ -13,7 +13,7 @@ _pg_users()
|
||||
{
|
||||
# See https://launchpad.net/bugs/164772
|
||||
#COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
|
||||
# grep "^ $cur" ) )
|
||||
# command grep "^ $cur" ) )
|
||||
#[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
|
||||
COMPREPLY=( $( compgen -u -- "$cur" ) )
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ _povray()
|
||||
;;
|
||||
[-+]O*)
|
||||
# guess what output file type user may want
|
||||
case $( ( IFS=$'\n'; grep '^[-+]F' <<<"${COMP_WORDS[*]}" ) ) in
|
||||
case $( ( IFS=$'\n'; command grep '^[-+]F' <<<"${COMP_WORDS[*]}" ) ) in
|
||||
[-+]FN) oext=png ;;
|
||||
[-+]FP) oext=ppm ;;
|
||||
[-+]F[CT]) oext=tga ;;
|
||||
*) oext=$defoext ;;
|
||||
esac
|
||||
# complete filename corresponding to previously specified +I
|
||||
COMPREPLY=( $( ( IFS=$'\n'; grep '^[-+]I' <<<"${COMP_WORDS[*]}" ) ) )
|
||||
COMPREPLY=( $( ( IFS=$'\n'; command grep '^[-+]I' <<<"${COMP_WORDS[*]}" ) ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
|
||||
COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
|
||||
cur="${povcur#[-+]O}" # to confuse _filedir
|
||||
|
@ -13,7 +13,7 @@ _rdesktop()
|
||||
-k)
|
||||
COMPREPLY=( $( command ls \
|
||||
/usr/share/rdesktop/keymaps 2>/dev/null | \
|
||||
grep -E -v '(common|modifiers)' ) )
|
||||
command grep -E -v '(common|modifiers)' ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \
|
||||
$HOME/.rdesktop/keymaps 2>/dev/null ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $( command ls \
|
||||
|
@ -14,7 +14,7 @@ _rpcdebug_flags()
|
||||
|
||||
if [ -n "$module" ]; then
|
||||
COMPREPLY=( $( compgen -W "$(rpcdebug -vh 2>&1 \
|
||||
| grep '^'$module' '\
|
||||
| command grep '^'$module' '\
|
||||
| awk '{$1 = ""; print $0}')" -- "$cur" ) )
|
||||
fi
|
||||
}
|
||||
|
@ -12,16 +12,16 @@ _sitecopy()
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
COMPREPLY=( $( compgen -W "$(sitecopy -h | grep -e '--\w' | \
|
||||
COMPREPLY=( $( compgen -W "$(sitecopy -h | command grep -e '--\w' |\
|
||||
awk '{sub (/=(FILE|PATH)/, "", $2); print $2}')" -- "$cur" ) )
|
||||
;;
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "$(sitecopy -h | grep -e '-\w' | \
|
||||
COMPREPLY=( $( compgen -W "$(sitecopy -h | command grep -e '-\w' | \
|
||||
awk '{sub (",", "", $1); print $1}')" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
if [ -r ~/.sitecopyrc ]; then
|
||||
COMPREPLY=( $( compgen -W "$(grep '^["$'\t '"]*site' \
|
||||
COMPREPLY=( $( compgen -W "$(command grep '^["$'\t '"]*site' \
|
||||
~/.sitecopyrc | awk '{print $2}')" -- "$cur" ) )
|
||||
fi
|
||||
;;
|
||||
|
@ -101,7 +101,7 @@ _xvnc4viewer()
|
||||
)
|
||||
[[ "$cur" == --* ]] && dash=-- || dash=-
|
||||
# Is a `nocasematch' variable available (bash > v3.1)?
|
||||
if shopt nocasematch 2> /dev/null | grep -q ^nocasematch; then
|
||||
if shopt nocasematch 2> /dev/null | command grep -q ^nocasematch; then
|
||||
# Variable `nocasematch' is available
|
||||
# Use vncviewer camelcase options
|
||||
local option oldNoCaseMatch=$(shopt -p nocasematch)
|
||||
|
@ -35,7 +35,7 @@ _wvdial()
|
||||
# parse config files for sections and
|
||||
# remove default section
|
||||
COMPREPLY=( $( sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \
|
||||
2>/dev/null |grep -v '^Defaults$'))
|
||||
2>/dev/null | command grep -v '^Defaults$'))
|
||||
# escape spaces
|
||||
COMPREPLY=${COMPREPLY// /\\ }
|
||||
;;
|
||||
|
@ -10,7 +10,7 @@ _xrandr()
|
||||
|
||||
case "$prev" in
|
||||
--output)
|
||||
local outputs=$(xrandr|grep 'connected'|awk '{print $1}')
|
||||
local outputs=$(xrandr|command grep 'connected'|awk '{print $1}')
|
||||
COMPREPLY=( $(compgen -W "$outputs" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
|
@ -18,7 +18,7 @@ sync_after_int
|
||||
|
||||
|
||||
# Build list of installed packages
|
||||
if {[assert_exec {dpkg --get-selections | grep \[\[:space:\]\]install$ | cut -f1} packages]} {
|
||||
if {[assert_exec {dpkg --get-selections | command grep \[\[:space:\]\]install$ | cut -f1} packages]} {
|
||||
assert_complete $packages "dpkg -L "
|
||||
}; # if
|
||||
|
||||
|
@ -429,7 +429,7 @@ proc get_hosts_avahi {} {
|
||||
# Retrieving hosts is successful?
|
||||
if { [catch {exec bash -c {
|
||||
type avahi-browse >&/dev/null \
|
||||
&& avahi-browse -cpr _workstation._tcp 2>/dev/null | grep ^= | cut -d\; -f7 | sort -u
|
||||
&& avahi-browse -cpr _workstation._tcp 2>/dev/null | command grep ^= | cut -d\; -f7 | sort -u
|
||||
}} hosts] } {
|
||||
# No, retrieving hosts yields error;
|
||||
# Reset hosts
|
||||
|
Loading…
x
Reference in New Issue
Block a user