add_members, bk, gcc, mtx, munin-run, munindoc, mutt, p4, portinstall, postmap, ri, ypmatch: Avoid stderr spewage when needed commands/dirs are not available.
This commit is contained in:
parent
5afc526850
commit
e850ee015e
@ -2,7 +2,7 @@
|
||||
|
||||
_mailman_lists()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( list_lists -b )' -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W '$( list_lists -b 2>/dev/null )' -- "$cur" ) )
|
||||
}
|
||||
|
||||
_add_members()
|
||||
|
@ -5,8 +5,8 @@ _bk()
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local BKCMDS="$( bk help topics | awk '/^ bk/ { print $4 }' | \
|
||||
xargs printf '%s ' )"
|
||||
local BKCMDS="$( bk help topics 2>/dev/null | \
|
||||
awk '/^ bk/ { print $4 }' | xargs printf '%s ' )"
|
||||
|
||||
COMPREPLY=( $( compgen -W "$BKCMDS" -- "$cur" ) )
|
||||
_filedir
|
||||
|
@ -33,7 +33,8 @@ _gcc()
|
||||
esac
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
cc=$( $1 -print-prog-name=$backend )
|
||||
cc=$( $1 -print-prog-name=$backend 2>/dev/null )
|
||||
[[ $cc ]] || return
|
||||
# sink stderr:
|
||||
# for C/C++/ObjectiveC it's useless
|
||||
# for FORTRAN/Java it's an error
|
||||
|
@ -10,11 +10,11 @@ _mtx()
|
||||
options="-f nobarcode invert noattach --version inquiry noattach \
|
||||
inventory status load unload eepos first last next"
|
||||
|
||||
tapes=$(mtx status | \
|
||||
tapes=$(mtx status 2>/dev/null | \
|
||||
awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
|
||||
tapes=${tapes//:Full}
|
||||
|
||||
drives=$(mtx status | \
|
||||
drives=$(mtx status 2>/dev/null | \
|
||||
awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
|
||||
drives=${drives//:Full}
|
||||
drives=${drives//:Empty}
|
||||
|
@ -19,8 +19,8 @@ _munin_run()
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
||||
else
|
||||
COMPREPLY=( $( compgen -W '$( command ls /etc/munin/plugins )' \
|
||||
-- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'$( command ls /etc/munin/plugins 2>/dev/null )' -- "$cur" ) )
|
||||
fi
|
||||
} &&
|
||||
complete -F _munin_run munin-run
|
||||
|
@ -5,8 +5,8 @@ _munindoc()
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
COMPREPLY=( $( compgen -W '$( command ls /usr/share/munin/plugins )' \
|
||||
-- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'$( command ls /usr/share/munin/plugins 2>/dev/null )' -- "$cur" ) )
|
||||
} &&
|
||||
complete -F _munindoc munindoc
|
||||
|
||||
|
@ -95,7 +95,7 @@ _muttquery()
|
||||
local cur=$1 querycmd muttcmd=${words[0]}
|
||||
local -a queryresults
|
||||
|
||||
querycmd="$( $muttcmd -Q query_command | sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|' )"
|
||||
querycmd="$( $muttcmd -Q query_command 2>/dev/null | sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|' )"
|
||||
if [[ -z "$cur" || -z "$querycmd" ]]; then
|
||||
queryresults=()
|
||||
else
|
||||
@ -117,7 +117,7 @@ _muttfiledir()
|
||||
|
||||
muttrc=$(_muttrc)
|
||||
if [[ $cur == [=+]* ]]; then
|
||||
folder="$( $muttcmd -F "$muttrc" -Q folder | sed -e 's|^folder=\"\(.*\)\"$|\1|' )"
|
||||
folder="$( $muttcmd -F "$muttrc" -Q folder 2>/dev/null | sed -e 's|^folder=\"\(.*\)\"$|\1|' )"
|
||||
: folder:=~/Mail
|
||||
|
||||
# Match any file in $folder beginning with $cur
|
||||
@ -127,7 +127,7 @@ _muttfiledir()
|
||||
COMPREPLY=( ${COMPREPLY[@]#$folder/} )
|
||||
return 0
|
||||
elif [ "$cur" == !* ]; then
|
||||
spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile | \
|
||||
spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \
|
||||
sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )"
|
||||
[ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}"
|
||||
fi
|
||||
|
@ -8,7 +8,7 @@ _p4()
|
||||
local p4commands p4filetypes
|
||||
|
||||
# rename isn't really a command
|
||||
p4commands="$( p4 help commands | awk 'NF>3 {print $1}' )"
|
||||
p4commands="$( p4 help commands 2>/dev/null | awk 'NF>3 {print $1}' )"
|
||||
p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
|
||||
uresource uxbinary xbinary xltext xtempobj xtext \
|
||||
text binary resource"
|
||||
|
@ -18,9 +18,10 @@ _portinstall()
|
||||
|
||||
[[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
|
||||
|
||||
COMPREPLY=( $( command grep -E "^$cur" < $indexfile | cut -d'|' -f1 ) )
|
||||
COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" < $indexfile | \
|
||||
cut -d'|' -f2 ) )
|
||||
COMPREPLY=( $( command grep -E "^$cur" 2>/dev/null < $indexfile | \
|
||||
cut -d'|' -f1 ) )
|
||||
COMPREPLY2=( $( command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \
|
||||
< $indexfile | cut -d'|' -f2 ) )
|
||||
COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
|
||||
COMPREPLY+=( "${COMPREPLY2[@]}" )
|
||||
|
||||
|
@ -25,7 +25,7 @@ _postmap()
|
||||
COMPREPLY=( $( compgen -f -- "${cur#*:}" ) )
|
||||
else
|
||||
local len=${#cur} idx=0 pval
|
||||
for pval in $( /usr/sbin/postconf -m ); do
|
||||
for pval in $( /usr/sbin/postconf -m 2>/dev/null ); do
|
||||
if [[ "$cur" == "${pval:0:$len}" ]]; then
|
||||
COMPREPLY[$idx]="$pval:"
|
||||
idx=$(($idx+1))
|
||||
|
@ -17,7 +17,7 @@ ri_get_methods()
|
||||
"$( ri ${classes[@]} 2>/dev/null | ruby -ane \
|
||||
'if /^'"$regex"' methods:/.../^------------------|^$/ and \
|
||||
/^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
|
||||
end' | sort -u )" )
|
||||
end' 2>/dev/null | sort -u )" )
|
||||
else
|
||||
# older versions of ri didn't distinguish between class/module and
|
||||
# instance methods
|
||||
@ -61,8 +61,8 @@ _ri()
|
||||
|
||||
if [ "$ri_version" = integrated ]; then
|
||||
# integrated ri from Ruby 1.9
|
||||
classes=( $( ri -c | ruby -ne 'if /^\s*$/..$stdin.eof then \
|
||||
if /, [A-Z]+/ then print; end; end' ) )
|
||||
classes=( $( ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
|
||||
if /, [A-Z]+/ then print; end; end' 2>/dev/null ) )
|
||||
elif [ "$ri_version" = "ri 1.8a" ]; then
|
||||
classes=( $( ruby -W0 $ri_path | \
|
||||
ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
|
||||
|
@ -12,12 +12,13 @@ _ypmatch()
|
||||
|
||||
if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then
|
||||
map=${words[2]}
|
||||
COMPREPLY=( $( compgen -W '$( ypcat $map | \
|
||||
COMPREPLY=( $( compgen -W '$( ypcat $map 2>/dev/null | \
|
||||
cut -d':' -f 1 )' -- "$cur") )
|
||||
else
|
||||
[[ $cmd == ypmatch && $cword -ne 2 ]] && return 0
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
|
||||
'$( printf "%s\n" $(ypcat -x 2>/dev/null | \
|
||||
cut -d"\"" -f 2) )' -- "$cur") )
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user