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