[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 8caddc47cfb38ff639ce9e6e8cf0ead7add17328
Ville Skyttä
ville.skytta at iki.fi
Tue Dec 15 21:50:05 UTC 2009
The following commit has been merged in the master branch:
commit 8caddc47cfb38ff639ce9e6e8cf0ead7add17328
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Tue Dec 15 23:48:10 2009 +0200
Protect grep invocations from user aliases (Alioth: 312143).
diff --git a/CHANGES b/CHANGES
index 3d9c0d7..b7c1785 100644
--- a/CHANGES
+++ b/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)
diff --git a/bash_completion b/bash_completion
index 5d8fa22..f33f85a 100644
--- a/bash_completion
+++ b/bash_completion
@@ -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
diff --git a/contrib/_modules b/contrib/_modules
index eb6da51..960ed2b 100644
--- a/contrib/_modules
+++ b/contrib/_modules
@@ -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") )
diff --git a/contrib/apt b/contrib/apt
index 5c72b95..7775816 100644
--- a/contrib/apt
+++ b/contrib/apt
@@ -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
;;
diff --git a/contrib/aptitude b/contrib/aptitude
index e391047..e4c8b68 100644
--- a/contrib/aptitude
+++ b/contrib/aptitude
@@ -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
;;
diff --git a/contrib/bitkeeper b/contrib/bitkeeper
index 3e1641a..97830b9 100644
--- a/contrib/bitkeeper
+++ b/contrib/bitkeeper
@@ -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
diff --git a/contrib/cfengine b/contrib/cfengine
index 561a564..2f75802 100644
--- a/contrib/cfengine
+++ b/contrib/cfengine
@@ -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
;;
diff --git a/contrib/dpkg b/contrib/dpkg
index 709efc2..b203d58 100644
--- a/contrib/dpkg
+++ b/contrib/dpkg
@@ -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
}
}
diff --git a/contrib/isql b/contrib/isql
index ff4ad88..fef0c0a 100644
--- a/contrib/isql
+++ b/contrib/isql
@@ -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
diff --git a/contrib/java b/contrib/java
index 58562f5..4f669b3 100644
--- a/contrib/java
+++ b/contrib/java
@@ -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
diff --git a/contrib/perl b/contrib/perl
index 9a6c479..d59314c 100644
--- a/contrib/perl
+++ b/contrib/perl
@@ -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
}
diff --git a/contrib/portupgrade b/contrib/portupgrade
index 91278eb..d66fca9 100644
--- a/contrib/portupgrade
+++ b/contrib/portupgrade
@@ -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[@]}" )
diff --git a/contrib/postgresql b/contrib/postgresql
index d63301d..09ec2cb 100644
--- a/contrib/postgresql
+++ b/contrib/postgresql
@@ -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" ) )
}
diff --git a/contrib/povray b/contrib/povray
index c56a71f..b98c081 100644
--- a/contrib/povray
+++ b/contrib/povray
@@ -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
diff --git a/contrib/rdesktop b/contrib/rdesktop
index d79ba4e..799d545 100644
--- a/contrib/rdesktop
+++ b/contrib/rdesktop
@@ -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 \
diff --git a/contrib/rpcdebug b/contrib/rpcdebug
index 196d187..525ab7d 100644
--- a/contrib/rpcdebug
+++ b/contrib/rpcdebug
@@ -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
}
diff --git a/contrib/sitecopy b/contrib/sitecopy
index 9d82d77..50302e5 100644
--- a/contrib/sitecopy
+++ b/contrib/sitecopy
@@ -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
;;
diff --git a/contrib/vncviewer b/contrib/vncviewer
index dd2525a..3e04f79 100644
--- a/contrib/vncviewer
+++ b/contrib/vncviewer
@@ -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)
diff --git a/contrib/wvdial b/contrib/wvdial
index 9081f6f..10d9c2c 100644
--- a/contrib/wvdial
+++ b/contrib/wvdial
@@ -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// /\\ }
;;
diff --git a/contrib/xrandr b/contrib/xrandr
index 1036945..e9ac632 100644
--- a/contrib/xrandr
+++ b/contrib/xrandr
@@ -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
;;
diff --git a/test/lib/completions/dpkg.exp b/test/lib/completions/dpkg.exp
index 9e01882..2bd1fb6 100644
--- a/test/lib/completions/dpkg.exp
+++ b/test/lib/completions/dpkg.exp
@@ -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
diff --git a/test/lib/library.exp b/test/lib/library.exp
index c6a290e..7215d2a 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -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
--
bash-completion
More information about the Bash-completion-commits
mailing list