Use [[ ]] when appropriate per current style guidelines.
parent
29baa6b720
commit
b424bfe37b
|
@ -578,7 +578,7 @@ _expand()
|
|||
|
||||
# This function completes on process IDs.
|
||||
# AIX and Solaris ps prefers X/Open syntax.
|
||||
[ $UNAME = SunOS -o $UNAME = AIX ] &&
|
||||
[[ $UNAME == SunOS || $UNAME == AIX ]] &&
|
||||
_pids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps -efo pid | sed 1d )' -- "$cur" ))
|
||||
|
@ -590,7 +590,7 @@ _pids()
|
|||
|
||||
# This function completes on process group IDs.
|
||||
# AIX and SunOS prefer X/Open, all else should be BSD.
|
||||
[ $UNAME = SunOS -o $UNAME = AIX ] &&
|
||||
[[ $UNAME == SunOS || $UNAME == AIX ]] &&
|
||||
_pgids()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps -efo pgid | sed 1d )' -- "$cur" ))
|
||||
|
@ -602,7 +602,7 @@ _pgids()
|
|||
|
||||
# This function completes on process names.
|
||||
# AIX and SunOS prefer X/Open, all else should be BSD.
|
||||
[ $UNAME = SunOS -o $UNAME = AIX ] &&
|
||||
[[ $UNAME == SunOS || $UNAME == AIX ]] &&
|
||||
_pnames()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W '$( command ps -efo comm | \
|
||||
|
@ -888,8 +888,7 @@ _chgrp()
|
|||
fi
|
||||
|
||||
# first parameter on line or first since an option?
|
||||
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
|
||||
[[ "$prev" == -* ]]; then
|
||||
if [[ $COMP_CWORD -eq 1 && "$cur" != -* || "$prev" == -* ]]; then
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( compgen -g "$cur" 2>/dev/null ) )
|
||||
else
|
||||
|
@ -935,7 +934,7 @@ _mount()
|
|||
|
||||
for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
|
||||
|
||||
if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
|
||||
if [[ -n "$sm" && "$cur" == *:* ]]; then
|
||||
COMPREPLY=( $( compgen -W "$( $sm -e ${cur%%:*} | sed 1d | \
|
||||
awk '{print $1}' )" -- "$cur" ) )
|
||||
elif [[ "$cur" == //* ]]; then
|
||||
|
@ -1000,8 +999,7 @@ _insmod()
|
|||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
# behave like lsmod for modprobe -r
|
||||
if [ ${1##*/} = "modprobe" ] &&
|
||||
[ "${COMP_WORDS[1]}" = "-r" ]; then
|
||||
if [[ ${1##*/} == modprobe && "${COMP_WORDS[1]}" == -r ]]; then
|
||||
_installed_modules "$cur"
|
||||
return 0
|
||||
fi
|
||||
|
@ -1012,8 +1010,7 @@ _insmod()
|
|||
return 0
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD -gt 1 ] &&
|
||||
[[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
|
||||
if [[ $COMP_CWORD -gt 1 && "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
|
||||
# do module parameter completion
|
||||
COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p ${COMP_WORDS[1]} | \
|
||||
cut -d: -f1 )" -- "$cur" ) )
|
||||
|
@ -1039,7 +1036,7 @@ _renice()
|
|||
|
||||
i=0
|
||||
# walk back through command line and find last option
|
||||
while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
|
||||
while [[ $i -le $COMP_CWORD && ${#COMPREPLY[@]} -eq 0 ]]; do
|
||||
curopt=${COMP_WORDS[COMP_CWORD-$i]}
|
||||
case "$curopt" in
|
||||
-u)
|
||||
|
@ -1067,7 +1064,7 @@ _kill()
|
|||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
|
||||
if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then
|
||||
# return list of available signals
|
||||
_signals
|
||||
else
|
||||
|
@ -1079,7 +1076,7 @@ complete -F _kill kill
|
|||
|
||||
# killall(1) (Linux and FreeBSD) and pkill(1) completion.
|
||||
#
|
||||
[ $UNAME = Linux -o $UNAME = FreeBSD ] || have pkill &&
|
||||
[[ $UNAME == Linux || $UNAME == FreeBSD ]] || have pkill &&
|
||||
_killall()
|
||||
{
|
||||
local cur
|
||||
|
@ -1087,7 +1084,7 @@ _killall()
|
|||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
|
||||
if [[ $COMP_CWORD -eq 1 && "$cur" == -* ]]; then
|
||||
_signals
|
||||
else
|
||||
_pnames
|
||||
|
@ -1095,7 +1092,7 @@ _killall()
|
|||
|
||||
return 0
|
||||
}
|
||||
[ $UNAME = Linux -o $UNAME = FreeBSD ] && complete -F _killall killall
|
||||
[[ $UNAME == Linux || $UNAME == FreeBSD ]] && complete -F _killall killall
|
||||
have pkill && complete -F _killall pkill
|
||||
|
||||
# pgrep(1) completion.
|
||||
|
@ -1208,8 +1205,8 @@ _known_hosts()
|
|||
|
||||
# NOTE: Using `_known_hosts' as a helper function and passing options
|
||||
# to `_known_hosts' is deprecated: Use `_known_hosts_real' instead.
|
||||
[ "$1" = -a ] || [ "$2" = -a ] && options=-a
|
||||
[ "$1" = -c ] || [ "$2" = -c ] && options="$options -c"
|
||||
[[ "$1" == -a || "$2" == -a ]] && options=-a
|
||||
[[ "$1" == -c || "$2" == -c ]] && options="$options -c"
|
||||
_known_hosts_real $options "$(_get_cword :)"
|
||||
} # _known_hosts()
|
||||
|
||||
|
@ -1303,7 +1300,7 @@ _known_hosts_real()
|
|||
fi
|
||||
|
||||
# If we have known_hosts files to use
|
||||
if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 -o -n "$configfile" ]; then
|
||||
if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 || -n "$configfile" ]]; then
|
||||
# Escape slashes and dots in paths for awk
|
||||
awkcur=${cur//\//\\\/}
|
||||
awkcur=${awkcur//\./\\\.}
|
||||
|
@ -1339,7 +1336,7 @@ _known_hosts_real()
|
|||
# dont fork any processes, because in a cluster environment,
|
||||
# there can be hundreds of hostkeys
|
||||
for i in "${khd[@]}" ; do
|
||||
if [[ "$i" == *key_22_$awkcurd*.pub ]] && [ -r "$i" ] ; then
|
||||
if [[ "$i" == *key_22_$awkcurd*.pub && -r "$i" ]]; then
|
||||
host=${i/#*key_22_/}
|
||||
host=${host/%.pub/}
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $host )
|
||||
|
@ -1347,7 +1344,7 @@ _known_hosts_real()
|
|||
done
|
||||
fi
|
||||
# append any available aliases from config files
|
||||
if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
|
||||
if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
|
||||
local host_aliases=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\?$/\2/p' "${config[@]}" )
|
||||
hosts=$( compgen -W "$host_aliases" -- "$cur" )
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $hosts )
|
||||
|
@ -1404,7 +1401,7 @@ _cd()
|
|||
|
||||
# Use standard dir completion if no CDPATH or parameter starts with /,
|
||||
# ./ or ../
|
||||
if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
|
||||
if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then
|
||||
_filedir -d
|
||||
return 0
|
||||
fi
|
||||
|
@ -1428,7 +1425,7 @@ _cd()
|
|||
|
||||
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
|
||||
i=${COMPREPLY[0]}
|
||||
if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
|
||||
if [[ "$i" == "$cur" && $i != "*/" ]]; then
|
||||
COMPREPLY[0]="${i}/"
|
||||
fi
|
||||
fi
|
||||
|
@ -1687,27 +1684,27 @@ fi
|
|||
unset list
|
||||
|
||||
# source completion directory definitions
|
||||
if [ -d $BASH_COMPLETION_COMPAT_DIR -a -r $BASH_COMPLETION_COMPAT_DIR -a \
|
||||
-x $BASH_COMPLETION_COMPAT_DIR ]; then
|
||||
if [[ -d $BASH_COMPLETION_COMPAT_DIR && -r $BASH_COMPLETION_COMPAT_DIR && \
|
||||
-x $BASH_COMPLETION_COMPAT_DIR ]]; then
|
||||
for i in $(LC_ALL=C command ls $BASH_COMPLETION_COMPAT_DIR); do
|
||||
i=$BASH_COMPLETION_COMPAT_DIR/$i
|
||||
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) ]] &&
|
||||
[ \( -f $i -o -h $i \) -a -r $i ] && . $i
|
||||
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) \
|
||||
&& ( -f $i || -h $i ) && -r $i ]] && . $i
|
||||
done
|
||||
fi
|
||||
if [ -d $BASH_COMPLETION_DIR -a -r $BASH_COMPLETION_DIR -a \
|
||||
$BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR -a \
|
||||
-x $BASH_COMPLETION_DIR ]; then
|
||||
if [[ $BASH_COMPLETION_DIR != $BASH_COMPLETION_COMPAT_DIR && \
|
||||
-d $BASH_COMPLETION_DIR && -r $BASH_COMPLETION_DIR && \
|
||||
-x $BASH_COMPLETION_DIR ]]; then
|
||||
for i in $(LC_ALL=C command ls $BASH_COMPLETION_DIR); do
|
||||
i=$BASH_COMPLETION_DIR/$i
|
||||
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) ]] &&
|
||||
[ \( -f $i -o -h $i \) -a -r $i ] && . $i
|
||||
[[ ${i##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|*.rpm@(orig|new|save)) \
|
||||
&& ( -f $i || -h $i ) && -r $i ]] && . $i
|
||||
done
|
||||
fi
|
||||
unset i
|
||||
|
||||
# source user completion file
|
||||
[ $BASH_COMPLETION != ~/.bash_completion -a -r ~/.bash_completion ] \
|
||||
[[ $BASH_COMPLETION != ~/.bash_completion && -r ~/.bash_completion ]] \
|
||||
&& . ~/.bash_completion
|
||||
unset -f have
|
||||
unset UNAME USERLAND have
|
||||
|
|
|
@ -11,7 +11,7 @@ _abook()
|
|||
|
||||
# abook only takes options, tabbing after command name adds a single
|
||||
# dash (bash4)
|
||||
[ ${BASH_VERSINFO[0]} -ge 4 -a $COMP_CWORD -eq 1 -a -z "$cur" ] &&
|
||||
[[ ${BASH_VERSINFO[0]} -ge 4 && $COMP_CWORD -eq 1 && -z "$cur" ]] &&
|
||||
{
|
||||
compopt -o nospace
|
||||
COMPREPLY=( "-" )
|
||||
|
|
|
@ -27,7 +27,7 @@ _chkconfig()
|
|||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '--list --add --del --override --level' -- "$cur" ) )
|
||||
else
|
||||
if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
|
||||
if [[ $COMP_CWORD -eq 2 || $COMP_CWORD -eq 4 ]]; then
|
||||
COMPREPLY=( $( compgen -W 'on off reset resetpriorities' -- "$cur" ) )
|
||||
else
|
||||
_services
|
||||
|
|
|
@ -34,7 +34,7 @@ _cpan2dist()
|
|||
else
|
||||
cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" )
|
||||
for dir in ${cpandirs[@]}; do
|
||||
[ -d "$dir" -a -r "$dir/02packages.details.txt.gz" ] && \
|
||||
[[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \
|
||||
packagelist="$dir/02packages.details.txt.gz"
|
||||
done
|
||||
COMPREPLY=( $( zgrep "^${cur//-/::}" \
|
||||
|
|
|
@ -56,7 +56,7 @@ _cvs()
|
|||
for i in "${COMP_WORDS[@]}"; do
|
||||
[ $count -eq $COMP_CWORD ] && break
|
||||
# Last parameter was the CVSROOT, now go back to mode selection
|
||||
if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
|
||||
if [[ "${COMP_WORDS[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
|
||||
mode=""
|
||||
fi
|
||||
if [ -z "$mode" ]; then
|
||||
|
@ -144,7 +144,7 @@ _cvs()
|
|||
|
||||
if [[ "$cur" != -* ]]; then
|
||||
set_prefix
|
||||
if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
|
||||
if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
get_entries
|
||||
[ -z "$cur" ] && \
|
||||
files=$( command ls -Ad !(CVS) ) || \
|
||||
|
@ -293,7 +293,7 @@ _cvs()
|
|||
remove)
|
||||
if [[ "$cur" != -* ]]; then
|
||||
set_prefix
|
||||
if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
|
||||
if [[ $COMP_CWORD -gt 1 && -r ${prefix:-}CVS/Entries ]]; then
|
||||
get_entries
|
||||
# find out what files are missing
|
||||
for i in "${entries[@]}"; do
|
||||
|
|
|
@ -167,7 +167,7 @@ _dpkg_source()
|
|||
done
|
||||
case "$action" in
|
||||
"unpack")
|
||||
if [ "$cur" = "-" -o "$cur" = "-s" ]; then
|
||||
if [[ "$cur" == - || "$cur" == -s ]]; then
|
||||
COMPREPLY=( $unpackopts )
|
||||
return 0
|
||||
fi
|
||||
|
|
|
@ -70,7 +70,7 @@ _find()
|
|||
done
|
||||
|
||||
# handle case where first parameter is not a dash option
|
||||
if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
|
||||
if [[ "$exprfound" != 1 && "$cur" != [-\(\),\!]* ]]; then
|
||||
_filedir -d
|
||||
return 0
|
||||
fi
|
||||
|
@ -94,8 +94,7 @@ _find()
|
|||
-noleaf -version -xdev '
|
||||
COMPREPLY=( $( echo "${COMP_WORDS[@]}" | \
|
||||
(while read -d ' ' i; do
|
||||
[ "$i" == "" ] ||
|
||||
[ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
|
||||
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
|
||||
continue
|
||||
# flatten array with spaces on either side,
|
||||
# otherwise we cannot grep on word boundaries of
|
||||
|
|
|
@ -26,7 +26,7 @@ _gzip()
|
|||
elif [[ "$prev" == -* ]]; then
|
||||
[[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
|
||||
[[ "$prev" == -*f* ]] && xspec=
|
||||
elif [ "$prev" = '>' -o "$prev" = '>>' ]; then
|
||||
elif [[ "$prev" == '>' || "$prev" == '>>' ]]; then
|
||||
xspec=
|
||||
elif [ "$prev" = '<' ]; then
|
||||
xspec=
|
||||
|
|
|
@ -29,7 +29,7 @@ _iptables()
|
|||
COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) )
|
||||
;;
|
||||
-j)
|
||||
if [ "$table" = "-t filter" -o "$table" = "" ]; then
|
||||
if [[ "$table" == "-t filter" || -z "$table" ]]; then
|
||||
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
|
||||
`iptables $table -nL | sed -ne "$chain" \
|
||||
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
|
||||
|
|
|
@ -60,7 +60,7 @@ _java_classes()
|
|||
cur=${cur//.//}
|
||||
# parse each classpath element for classes
|
||||
for i in ${classpath//:/ }; do
|
||||
if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
|
||||
if [[ -r $i && "$i" == *.@(jar|zip) ]]; then
|
||||
if type zipinfo &>/dev/null; then
|
||||
COMPREPLY=( "${COMPREPLY[@]}" $( zipinfo -1 \
|
||||
"$i" "$cur*" 2>/dev/null | \
|
||||
|
|
|
@ -9,7 +9,7 @@ _larch()
|
|||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ] || [[ "$prev" == -* ]]; then
|
||||
if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W ' \
|
||||
my-id my-default-archive register-archive whereis-archive archives \
|
||||
init-tree tree-root tree-version set-tree-version inventory \
|
||||
|
|
|
@ -656,7 +656,7 @@ _vgsplit()
|
|||
--verbose --version' -- "$cur" ) )
|
||||
else
|
||||
_args
|
||||
if [ $args -eq 0 -o $args -eq 1 ]; then
|
||||
if [[ $args -eq 0 || $args -eq 1 ]]; then
|
||||
_volumegroups
|
||||
else
|
||||
_physicalvolumes
|
||||
|
|
|
@ -39,7 +39,7 @@ _mplayer()
|
|||
_filedir '@(idx|IDX|ifo|IFO|sub|SUB)'
|
||||
IFS=$'\t\n'
|
||||
COMPREPLY=( $( for i in "${COMPREPLY[@]}"; do
|
||||
if [ -f $i -a -r $i ]; then
|
||||
if [[ -f $i && -r $i ]]; then
|
||||
echo ${i%.*}
|
||||
else
|
||||
echo $i
|
||||
|
@ -67,7 +67,7 @@ _mplayer()
|
|||
|
||||
IFS=$'\t\n'
|
||||
for i in ~/.mplayer/Skin $skinsdir; do
|
||||
if [ -d $i -a -r $i ]; then
|
||||
if [[ -d $i && -r $i ]]; then
|
||||
for j in $( compgen -d $i/$cur ); do
|
||||
COMPREPLY[$k]=${j#$i/}
|
||||
k=$((++k))
|
||||
|
|
|
@ -94,7 +94,7 @@ _muttquery()
|
|||
local -a queryresults
|
||||
|
||||
querycmd="$( $muttcmd -Q query_command | sed -r 's|^query_command=\"(.*)\"$|\1|; s|%s|'$cur'|' )"
|
||||
if [ -z "$cur" -o -z "$querycmd" ]; then
|
||||
if [[ -z "$cur" || -z "$querycmd" ]]; then
|
||||
queryresults=()
|
||||
else
|
||||
queryresults=( $( $querycmd | sed -nr '2,$s|^([^[:space:]]+).*|\1|p' ) )
|
||||
|
|
|
@ -8,7 +8,7 @@ _ncftp()
|
|||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
if [ $COMP_CWORD -eq 1 ] && [ -f ~/.ncftp/bookmarks ]; then
|
||||
if [[ $COMP_CWORD -eq 1 && -f ~/.ncftp/bookmarks ]]; then
|
||||
COMPREPLY=( $( compgen -W '$( sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
|
||||
~/.ncftp/bookmarks )' -- "$cur" ) )
|
||||
fi
|
||||
|
|
|
@ -11,7 +11,7 @@ _pkg_delete()
|
|||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
[ "$prev" = "-o" -o "$prev" = "-p" -o "$prev" = "-W" ] && return 0
|
||||
[[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return 0
|
||||
|
||||
COMPREPLY=( $( compgen -d "$pkgdir$cur" ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
|
||||
|
|
|
@ -9,7 +9,7 @@ _portupgrade()
|
|||
cur=`_get_cword`
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
|
||||
[[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
|
||||
|
||||
COMPREPLY=( $( compgen -d "$pkgdir$cur" ) )
|
||||
COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
|
||||
|
@ -31,10 +31,10 @@ _portinstall()
|
|||
# First try INDEX-5
|
||||
indexfile=$portsdir/INDEX-5
|
||||
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
|
||||
[ "${OSTYPE%.*}" = "freebsd5" -a -f $indexfile ] ||
|
||||
indexfile=$portsdir/INDEX
|
||||
[[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] ||
|
||||
indexfile=$portsdir/INDEX
|
||||
|
||||
[ "$prev" = "-l" -o "$prev" = "-L" -o "$prev" = "-o" ] && return 0
|
||||
[[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return 0
|
||||
|
||||
COMPREPLY=( $( egrep "^$cur" < $indexfile | cut -d'|' -f1 ) )
|
||||
COMPREPLY2=( $( egrep "^[^\|]+\|$portsdir$cur" < $indexfile | \
|
||||
|
|
|
@ -31,7 +31,7 @@ _rcs()
|
|||
|
||||
# default to files if nothing returned and we're checking in.
|
||||
# otherwise, default to directories
|
||||
[ ${#COMPREPLY[@]} -eq 0 -a $1 = ci ] && _filedir || _filedir -d
|
||||
[[ ${#COMPREPLY[@]} -eq 0 && $1 == ci ]] && _filedir || _filedir -d
|
||||
} &&
|
||||
complete -F _rcs -o filenames ci co rlog rcs rcsdiff
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ _rfkill()
|
|||
;;
|
||||
2)
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
if [ $prev == block -o $prev == unblock ]; then
|
||||
if [[ $prev == block || $prev == unblock ]]; then
|
||||
COMPREPLY=( $( compgen -W "$(rfkill list | awk -F: \
|
||||
'/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \
|
||||
wwan gps" -- "$cur" ) )
|
||||
|
|
|
@ -7,8 +7,8 @@ _rpm_installed_packages()
|
|||
{
|
||||
local nodig="$1" nosig="$2"
|
||||
|
||||
if [ -r /var/log/rpmpkgs -a \
|
||||
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
|
||||
if [[ -r /var/log/rpmpkgs && \
|
||||
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
|
||||
# using RHL 7.2 or later - this is quicker than querying the DB
|
||||
COMPREPLY=( $( sed -ne \
|
||||
's|^\('$cur'[^[:space:]]*\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
|
||||
|
@ -33,7 +33,7 @@ _rpm_groups()
|
|||
|
||||
_rpm_nodigsig()
|
||||
{
|
||||
if [ -z "$nodig" -a -z "$nosig" ]; then
|
||||
if [[ -z "$nodig" && -z "$nosig" ]]; then
|
||||
local rpmver
|
||||
|
||||
rpmver=$(rpm --version)
|
||||
|
|
|
@ -8,16 +8,15 @@ _ypmatch()
|
|||
COMPREPLY=()
|
||||
cur=`_get_cword`
|
||||
|
||||
[ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
|
||||
[ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
|
||||
[[ $1 == ypcat && $COMP_CWORD -gt 1 ]] && return 0
|
||||
[[ $1 == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
|
||||
|
||||
if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
|
||||
[ ${#COMP_WORDS[@]} -eq 3 ]; then
|
||||
if [[ $1 == ypmatch && $COMP_CWORD -eq 1 && ${#COMP_WORDS[@]} -eq 3 ]]; then
|
||||
map=${COMP_WORDS[2]}
|
||||
COMPREPLY=( $( compgen -W '$( ypcat $map | \
|
||||
cut -d':' -f 1 )' -- "$cur") )
|
||||
else
|
||||
[ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
|
||||
[[ $1 == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
|
||||
COMPREPLY=( $( compgen -W \
|
||||
'$( echo $(ypcat -x | cut -d"\"" -f 2))' -- "$cur"))
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue