Replace all internal uses of grep with sgrep, which is a wrapper around grep that strips away any GREP_OPTIONS. This is needed to avoid users who have added arbitrary switches to GREP_OPTIONS, thus changing its behaviour.

darcs-hash:20061129140004-ac50b-485ff6bfd71e9459ba62461f6e093ca5c9ddd664.gz
This commit is contained in:
axel 2006-11-30 00:00:04 +10:00
parent 32502bfac8
commit f64364cced
25 changed files with 46 additions and 44 deletions

View file

@ -4,7 +4,7 @@ complete -f -c apt-proxy-import -s V -l version -d (N_ 'Display version and exit
complete -f -c apt-proxy-import -s v -l verbose -d (N_ 'Verbose mode')
complete -f -c apt-proxy-import -s q -l quiet -d (N_ 'No message to STDOUT')
complete -f -c apt-proxy-import -s r -l recursive -d (N_ 'Recurse into subdir')
complete -r -c apt-proxy-import -s i -l import-dir -a '(ls -Fp|grep /\$)' -d (N_ 'Dir to import')
complete -r -c apt-proxy-import -s i -l import-dir -a '(ls -Fp|sgrep /\$)' -d (N_ 'Dir to import')
complete -r -c apt-proxy-import -s u -l user -a '(__fish_complete_users)' -d (N_ 'Change to user')
complete -r -c apt-proxy-import -s d -l debug -d (N_ 'Debug level[default 0]')

View file

@ -2,8 +2,8 @@
complete -c apt-show-source -s h -l help -d (N_ 'Display help and exit')
complete -r -c apt-show-source -l status-file -d (N_ 'Read package from file') -f
complete -r -c apt-show-source -o stf -d (N_ 'Read package from file') -f
complete -r -c apt-show-source -l list-dir -a '(ls -Fp .|grep /\$) /var/lib/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-source -o ld -a '(ls -Fp .|grep /\$) /var/lib/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-source -l list-dir -a '(ls -Fp .|sgrep /\$) /var/lib/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-source -o ld -a '(ls -Fp .|sgrep /\$) /var/lib/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-source -s p -l package -a '(apt-cache pkgnames)' -d (N_ 'List PKG info')
complete -f -c apt-show-source -l version-only -d (N_ 'Display version and exit')
complete -f -c apt-show-source -s a -l all -d (N_ 'Print all source packages with version')

View file

@ -9,6 +9,6 @@ complete -f -c apt-show-versions -s v -l verbose -d (N_ 'Print verbose info')
complete -f -c apt-show-versions -s i -l initialize -d (N_ 'Init or update cache only')
complete -r -c apt-show-versions -l status-file -d (N_ 'Read package from file')
complete -r -c apt-show-versions -o stf -d (N_ 'Read package from file')
complete -r -c apt-show-versions -l list-dir -a '(ls -Fp .|grep /\$) /var/lib/apt/lists /var/state/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-versions -o ld -a '(ls -Fp .|grep /\$) /var/lib/apt/lists /var/state/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-versions -l list-dir -a '(ls -Fp .|sgrep /\$) /var/lib/apt/lists /var/state/apt/lists' -d (N_ 'Specify APT list dir')
complete -r -c apt-show-versions -o ld -a '(ls -Fp .|sgrep /\$) /var/lib/apt/lists /var/state/apt/lists' -d (N_ 'Specify APT list dir')

View file

@ -9,4 +9,4 @@ complete -c chown -s v -l verbose -d (N_ "Output diagnostic for every file")
complete -c chown -s h -l help -d (N_ "Display help and exit")
complete -c chown -l version -d (N_ "Display version and exit")
complete -c chown -d (N_ "Username") -a "(__fish_print_users):"
complete -c chown -d (N_ "Username") -a "(echo (commandline -ct)|grep -o '.*:')(cat /etc/group |cut -d : -f 1)"
complete -c chown -d (N_ "Username") -a "(echo (commandline -ct)|sgrep -o '.*:')(cat /etc/group |cut -d : -f 1)"

View file

@ -5,8 +5,8 @@
#
complete -c fusermount -d (N_ "Mount point") -x -a '
(
cat /etc/mtab | grep "^sshfs" | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|grep "^/"
cat /etc/mtab | grep "^fuseiso" | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|grep "^/"
cat /etc/mtab | sgrep "^sshfs" | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|sgrep "^/"
cat /etc/mtab | sgrep "^fuseiso" | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|sgrep "^/"
)
'

View file

@ -37,7 +37,7 @@ function __fish_print_gpg_algo -d "Complete using all algorithms of the type spe
# expire when the function goes out of scope, and the original locale
# will take effect again.
set -lx LC_ALL C
gpg --version | grep "$argv:"| grep -v "Home:"|cut -d : -f 2 |tr , \n|tr -d " "
gpg --version | sgrep "$argv:"| sgrep -v "Home:"|cut -d : -f 2 |tr , \n|tr -d " "
end

View file

@ -7,7 +7,7 @@ if kill -L ^/dev/null >/dev/null
complete -c kill -s L -d "List codes and names of available signals"
set -- signals (kill -L | sed -e 's/\([0-9][0-9]*\) *\([A-Z,0-9][A-Z,0-9]*\)/\1 \2\n/g;s/ +/ /g' | sed -e 's/^ //' | grep -E '^[^ ]+')
set -- signals (kill -L | sed -e 's/\([0-9][0-9]*\) *\([A-Z,0-9][A-Z,0-9]*\)/\1 \2\n/g;s/ +/ /g' | sed -e 's/^ //' | sgrep -E '^[^ ]+')
for i in $signals
set -- number (echo $i | cut -d " " -f 1)
set -- name (echo $i | cut -d " " -f 2)
@ -24,7 +24,7 @@ else
complete -c kill -s l -d "List codes and names of available signals"
for i in (kill -l|tr \ \t \n|grep '^[A-Z][A-Z0-9]*$')
for i in (kill -l|tr \ \t \n|sgrep '^[A-Z][A-Z0-9]*$')
complete -c kill -o $i -d Send\ $i\ signal
complete -c kill -o s -x -a $i\tSend\ $i\ signal -d "Send specified signal"
end

View file

@ -2,7 +2,7 @@
function __fish_print_make_targets
set files Makefile makefile GNUmakefile
grep -h -E '^[^#%=$[:space:]][^#%=$]*:([^=]|$)' $files | cut -d ":" -f 1 | sed -e 's/^ *//;s/ *$//;s/ */\n/g' ^/dev/null
sgrep -h -E '^[^#%=$[:space:]][^#%=$]*:([^=]|$)' $files | cut -d ":" -f 1 | sed -e 's/^ *//;s/ *$//;s/ */\n/g' ^/dev/null
end
# This completion is a bit ugly. It reenables file completion on
@ -10,7 +10,7 @@ end
# filename completion. Unfortunatly, this turns out to be a bit
# complicated to do.
set -l is_assignment "commandline -ct|grep '..*='"
set -l is_assignment "commandline -ct|sgrep '..*='"
set -l complete_file_assignment '(commandline -ct)(complete --do-complete=this_command_does_not_exist\ (commandline -ct|sed -e \'s/.*=//\'))'
complete -c make --condition $is_assignment -a $complete_file_assignment

View file

@ -4,7 +4,7 @@
# including mount and df
# Completions for mount
complete -x -c mount -a '(cat /etc/fstab|sed -e "s/^\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1\n\2/"|grep "^/")' -d (N_ 'Mount point')
complete -x -c mount -a '(cat /etc/fstab|sed -e "s/^\([^ \t]*\)[ \t]*\([^ \t]*\).*/\1\n\2/"|sgrep "^/")' -d (N_ 'Mount point')
complete -c mount -s V -d (N_ 'Display version and exit')
complete -c mount -s h -d (N_ 'Display help and exit')
complete -c mount -s v -d (N_ 'Verbose mode')

View file

@ -57,25 +57,25 @@ complete -c mplayer -o utf8 -d (N_ "Handle subtitlefile as utf8")
complete -c mplayer -o vo -x -d (N_ "Video output") -a "
(
mplayer -vo help|grep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/'
mplayer -vo help|sgrep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/'
)
"
complete -c mplayer -o ao -x -d (N_ "Audio output") -a "
(
mplayer -ao help|grep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/'
mplayer -ao help|sgrep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/'
)
"
complete -c mplayer -o afm -x -d (N_ "Audio output") -a "
(
__fish_append ',' (mplayer -afm help|grep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/')
__fish_append ',' (mplayer -afm help|sgrep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/')
)
"
complete -c mplayer -o vfm -x -d (N_ "Video output") -a "
(
__fish_append ',' (mplayer -vfm help|grep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/')
__fish_append ',' (mplayer -vfm help|sgrep \t.\*\t'\|^ *[a-zA-Z0-9][a-zA-Z0-9]* '|sed -e 's/[\t ]*\([a-zA-Z0-9]*\)[\t ]*\(.*\)/\1'\t'\2/')
)
"

View file

@ -1,5 +1,5 @@
function __fish_complete_screen -d (N_ "Print a list of running screen sessions")
screen -list |grep \^\t.\*\(.\*\)|sed -e 's/\t\(.*\)\t(\(.*\))/\1'\t'Screen: \2/'
screen -list |sgrep \^\t.\*\(.\*\)|sed -e 's/\t\(.*\)\t(\(.*\))/\1'\t'Screen: \2/'
end
complete -c screen -x

View file

@ -20,7 +20,7 @@ complete -c ssh -s a -d (N_ "Disables forwarding of the authentication agent")
complete -c ssh -s A -d (N_ "Enables forwarding of the authentication agent")
complete -x -c ssh -s b -d (N_ "Interface to transmit from") -a "
(
cat /proc/net/arp ^/dev/null| grep -v '^IP'|cut -d ' ' -f 1 ^/dev/null
cat /proc/net/arp ^/dev/null| sgrep -v '^IP'|cut -d ' ' -f 1 ^/dev/null
)
"

View file

@ -5,7 +5,7 @@
#
# Find all mountpoints
#
complete -c umount -d (N_ "Mount point") -x -a '(cat /etc/mtab | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|grep "^/")'
complete -c umount -d (N_ "Mount point") -x -a '(cat /etc/mtab | cut -d " " -f 1-2|tr " " \n|sed -e "s/[0-9\.]*:\//\//"|sgrep "^/")'
complete -c umount -s V -d (N_ "Display version and exit")
complete -c umount -s h -d (N_ "Display help and exit")

View file

@ -1,5 +1,5 @@
if valgrind --version | grep -- '-2\.[012]\.' >/dev/null ^/dev/null
if valgrind --version | sgrep -- '-2\.[012]\.' >/dev/null ^/dev/null
# In older versions of Valgrind, the skin selection option was
# '--skin'
set -g skin skin

View file

@ -76,7 +76,7 @@ end
set -l tmp (printf "%s" \^$PATH'/?$|')
set -l path_regexp \((echo $tmp | sed -e "s/.\$//")\)
for i in (printf "%s\n" $path_list|grep -E -v $path_regexp)
for i in (printf "%s\n" $path_list|sgrep -E -v $path_regexp)
if test -d $i
set PATH $PATH $i
end

View file

@ -197,7 +197,7 @@ function __fish_print_interfaces -d "Print a list of known network interfaces"
end
function __fish_print_addresses -d "Print a list of known network addresses"
/sbin/ifconfig |grep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1
/sbin/ifconfig |sgrep 'inet addr'|cut -d : -f 2|cut -d ' ' -f 1
end
function __fish_print_users -d "Print a list of local users"
@ -208,7 +208,7 @@ end
# Completions for the shell and it's builtin commands and functions
#
for i in (builtin -n|grep -E -v '(while|for|if|function|switch)' )
for i in (builtin -n|sgrep -E -v '(while|for|if|function|switch)' )
complete -c $i -s h -l help -d "Display help and exit"
end

View file

@ -18,7 +18,7 @@ function __fish_complete_cd -d "Completions for the cd command"
end
if echo (commandline -ct)|grep '^/\|^\./\|^\.\./' >/dev/null
if echo (commandline -ct)|sgrep '^/\|^\./\|^\.\./' >/dev/null
# This is an absolute search path
eval printf '\%s\\tDirectory\\n' (commandline -ct)\*/
else

View file

@ -21,7 +21,7 @@ function __fish_complete_man
set section $section"[^)]*"
# Do the actual search
apropos (commandline -ct) | grep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1'\t'\2: /p'
apropos (commandline -ct) | sgrep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1'\t'\2: /p'
end
end

View file

@ -29,11 +29,11 @@ function __fish_contains_opt -d "Checks if a specific option has been given in t
continue
end
if commandline -cpo | grep -- "^-"$i"\|^-[^-]*"$i >/dev/null
if commandline -cpo | sgrep -- "^-"$i"\|^-[^-]*"$i >/dev/null
return 0
end
if commandline -ct | grep -- "^-"$i"\|^-[^-]*"$i >/dev/null
if commandline -ct | sgrep -- "^-"$i"\|^-[^-]*"$i >/dev/null
return 0
end
end

View file

@ -3,11 +3,11 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
# Print all hosts from /etc/hosts
if test -f /etc/hosts
sed </etc/hosts -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|tr \t \n |grep -v '^$'
sed </etc/hosts -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|tr \t \n |sgrep -v '^$'
end
# Print nfs servers from /etc/fstab
if test -f /etc/fstab
grep </etc/fstab "^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\|[a-zA-Z.]*\):"|cut -d : -f 1
sgrep </etc/fstab "^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\|[a-zA-Z.]*\):"|cut -d : -f 1
end
# Print hosts with known ssh keys

View file

@ -18,7 +18,7 @@ function __fish_print_packages
# 2) Remove package names that are .so files, since these seem to not correspond to actual packages as reported by rpm
# 3) Remove path information such as /usr/bin/, as rpm packages do not have paths
apt-cache --no-generate pkgnames (commandline -tc)|grep -v \( |grep -v '\.so\(\.[0-9]\)*$'|sed -e 's/\/.*\///'|sed -e 's/$/'\t$package'/'
apt-cache --no-generate pkgnames (commandline -tc)|sgrep -v \( |sgrep -v '\.so\(\.[0-9]\)*$'|sed -e 's/\/.*\///'|sed -e 's/$/'\t$package'/'
return
end
@ -47,7 +47,7 @@ function __fish_print_packages
# True for installing new packages. Function for printing
# installed on the system packages is in completions/emerge.fish
if type -f emerge >/dev/null
emerge -s \^(commandline -tc) |grep "^*" |cut -d\ -f3 |cut -d/ -f2
emerge -s \^(commandline -tc) |sgrep "^*" |cut -d\ -f3 |cut -d/ -f2
return
end

View file

@ -32,14 +32,11 @@ function contains -d (N_ "Test if a key is contained in a set of values")
set -- key $argv[1]
set -e argv[1]
# Don't use any grep options!
set -l GREP_OPTIONS
#
# Loop through values
#
printf "%s\n" $argv|grep -Fx -- $key >/dev/null
printf "%s\n" $argv|sgrep -Fx -- $key >/dev/null
return $status
end

View file

@ -0,0 +1,5 @@
function sgrep -d "Call grep without honoring GREP_OPTIONS settings"
set -l GREP_OPTIONS
grep $argv
end

View file

@ -113,7 +113,7 @@ function trap -d 'Perform an action when the shell recives a signal'
if count $opt >/dev/null
set -- names $opt
else
set -- names (functions -na|grep "^__trap_handler_"|sed -e 's/__trap_handler_//' )
set -- names (functions -na|sgrep "^__trap_handler_"|sed -e 's/__trap_handler_//' )
end
for i in $names

View file

@ -1,12 +1,12 @@
function __fish_umask_parse -d "Internal umask function"
# Test if already a valid octal mask, and pad it with zeros
if echo $argv | grep -E '^(0|)[0-7]{1,3}$' >/dev/null
if echo $argv | sgrep -E '^(0|)[0-7]{1,3}$' >/dev/null
for i in (seq (echo 5-(echo $argv|wc -c)|bc)); set argv 0$argv; end
echo $argv
else
# Test if argument really is a valid symbolic mask
if not echo $argv | grep -E '^(((u|g|o|a|)(=|\+|-)|)(r|w|x)*)(,(((u|g|o|a|)(=|\+|-)|)(r|w|x)*))*$' >/dev/null
if not echo $argv | sgrep -E '^(((u|g|o|a|)(=|\+|-)|)(r|w|x)*)(,(((u|g|o|a|)(=|\+|-)|)(r|w|x)*))*$' >/dev/null
printf (_ "%s: Invalid mask '%s'\n") umask $argv >&2
return 1
end
@ -70,19 +70,19 @@ function __fish_umask_parse -d "Internal umask function"
set mode set
end
if not echo $perm|grep -E '^(r|w|x)*$' >/dev/null
if not echo $perm|sgrep -E '^(r|w|x)*$' >/dev/null
printf (_ "%s: Invalid mask '%s'\n") umask $argv >&2
return
end
set val 0
if echo $i |grep 'r' >/dev/null
if echo $i |sgrep 'r' >/dev/null
set val 4
end
if echo $i |grep 'w' >/dev/null
if echo $i |sgrep 'w' >/dev/null
set val (echo $val + 2|bc)
end
if echo $i |grep 'x' >/dev/null
if echo $i |sgrep 'x' >/dev/null
set val (echo $val + 1|bc)
end