Cleanups: Use [[ instead of [.

This commit is contained in:
Ville Skyttä 2011-11-09 23:28:11 +02:00
parent 1d48f79b9c
commit 3b8ef29ef3
76 changed files with 226 additions and 237 deletions

View File

@ -265,7 +265,7 @@ __reassemble_comp_words_by_ref()
ref="$2[$j]" ref="$2[$j]"
eval $2[$j]=\${!ref}\${COMP_WORDS[i]} eval $2[$j]=\${!ref}\${COMP_WORDS[i]}
# Indicate new cword # Indicate new cword
[ $i = $COMP_CWORD ] && eval $3=$j [[ $i == $COMP_CWORD ]] && eval $3=$j
# Remove optional whitespace + word separator from line copy # Remove optional whitespace + word separator from line copy
line=${line#*"${COMP_WORDS[$i]}"} line=${line#*"${COMP_WORDS[$i]}"}
# Start new word if word separator in original line is # Start new word if word separator in original line is
@ -480,7 +480,7 @@ _get_cword()
# #
_get_pword() _get_pword()
{ {
if [ $COMP_CWORD -ge 1 ]; then if [[ $COMP_CWORD -ge 1 ]]; then
_get_cword "${@:-}" 1 _get_cword "${@:-}" 1
fi fi
} }
@ -509,7 +509,7 @@ __ltrim_colon_completions()
# Remove colon-word prefix from COMPREPLY items # Remove colon-word prefix from COMPREPLY items
local colon_word=${1%${1##*:}} local colon_word=${1%${1##*:}}
local i=${#COMPREPLY[*]} local i=${#COMPREPLY[*]}
while [ $((--i)) -ge 0 ]; do while [[ $((--i)) -ge 0 ]]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}
done done
fi fi
@ -589,7 +589,7 @@ _filedir()
-n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \ -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \
toks+=( $( compgen -f -- $quoted ) ) toks+=( $( compgen -f -- $quoted ) )
[ ${#toks[@]} -ne 0 ] && compopt -o filenames 2>/dev/null [[ ${#toks[@]} -ne 0 ]] && compopt -o filenames 2>/dev/null
COMPREPLY+=( "${toks[@]}" ) COMPREPLY+=( "${toks[@]}" )
} # _filedir() } # _filedir()
@ -824,16 +824,16 @@ _mac_addresses()
# #
_configured_interfaces() _configured_interfaces()
{ {
if [ -f /etc/debian_version ]; then if [[ -f /etc/debian_version ]]; then
# Debian system # Debian system
COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\ COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\
/etc/network/interfaces )" -- "$cur" ) ) /etc/network/interfaces )" -- "$cur" ) )
elif [ -f /etc/SuSE-release ]; then elif [[ -f /etc/SuSE-release ]]; then
# SuSE system # SuSE system
COMPREPLY=( $( compgen -W "$( printf '%s\n' \ COMPREPLY=( $( compgen -W "$( printf '%s\n' \
/etc/sysconfig/network/ifcfg-* | \ /etc/sysconfig/network/ifcfg-* | \
sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) ) sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
elif [ -f /etc/pld-release ]; then elif [[ -f /etc/pld-release ]]; then
# PLD Linux # PLD Linux
COMPREPLY=( $( compgen -W "$( command ls -B \ COMPREPLY=( $( compgen -W "$( command ls -B \
/etc/sysconfig/interfaces | \ /etc/sysconfig/interfaces | \
@ -872,9 +872,9 @@ _available_interfaces()
{ {
local cmd local cmd
if [ "${1:-}" = -w ]; then if [[ ${1:-} == -w ]]; then
cmd="iwconfig" cmd="iwconfig"
elif [ "${1:-}" = -a ]; then elif [[ ${1:-} == -a ]]; then
cmd="ifconfig" cmd="ifconfig"
else else
cmd="ifconfig -a" cmd="ifconfig -a"
@ -905,7 +905,7 @@ _tilde()
# Try generate ~username completions # Try generate ~username completions
COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) ) COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) )
result=${#COMPREPLY[@]} result=${#COMPREPLY[@]}
[ $result -gt 0 ] && compopt -o filenames 2>/dev/null [[ $result -gt 0 ]] && compopt -o filenames 2>/dev/null
fi fi
return $result return $result
} }
@ -970,7 +970,7 @@ _expand()
elif [[ "$cur" == \~* ]]; then elif [[ "$cur" == \~* ]]; then
cur=${cur#\~} cur=${cur#\~}
COMPREPLY=( $( compgen -P '~' -u "$cur" ) ) COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
[ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]} [[ ${#COMPREPLY[@]} -eq 1 ]] && eval COMPREPLY[0]=${COMPREPLY[0]}
return ${#COMPREPLY[@]} return ${#COMPREPLY[@]}
fi fi
} }
@ -1095,7 +1095,7 @@ _service()
_init_completion || return _init_completion || return
# don't complete past 2nd token # don't complete past 2nd token
[ $cword -gt 2 ] && return 0 [[ $cword -gt 2 ]] && return 0
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
_services _services
@ -1112,7 +1112,7 @@ complete -F _service service
_sysvdirs _sysvdirs
for svcdir in ${sysvdirs[@]}; do for svcdir in ${sysvdirs[@]}; do
for svc in $svcdir/!($_backup_glob); do for svc in $svcdir/!($_backup_glob); do
[ -x "$svc" ] && complete -F _service $svc [[ -x $svc ]] && complete -F _service $svc
done done
done done
unset svc svcdir sysvdirs unset svc svcdir sysvdirs
@ -1228,7 +1228,7 @@ _fstypes()
{ {
local fss local fss
if [ -e /proc/filesystems ] ; then if [[ -e /proc/filesystems ]]; then
# Linux # Linux
fss="$( cut -d$'\t' -f2 /proc/filesystems ) fss="$( cut -d$'\t' -f2 /proc/filesystems )
$( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )" $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"
@ -1238,11 +1238,10 @@ _fstypes()
$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null )
$( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null ) $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null )
$( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null ) $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null )
$( [ -d /etc/fs ] && command ls /etc/fs )" $( [[ -d /etc/fs ]] && command ls /etc/fs )"
fi fi
[ -n "$fss" ] && \ [[ -n $fss ]] && COMPREPLY+=( $( compgen -W "$fss" -- "$cur" ) )
COMPREPLY+=( $( compgen -W "$fss" -- "$cur" ) )
} }
# Get real command. # Get real command.
@ -1396,26 +1395,25 @@ _known_hosts_real()
p) prefix=$OPTARG ;; p) prefix=$OPTARG ;;
esac esac
done done
[ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD" [[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
cur=${!OPTIND}; let "OPTIND += 1" cur=${!OPTIND}; let "OPTIND += 1"
[ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\ [[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
$(while [ $# -ge $OPTIND ]; do printf '%s\n' ${!OPTIND}; shift; done) $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done)
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@} [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
kh=() kh=()
# ssh config files # ssh config files
if [ -n "$configfile" ]; then if [[ -n $configfile ]]; then
[ -r "$configfile" ] && [[ -r $configfile ]] && config+=( "$configfile" )
config+=( "$configfile" )
else else
for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do
[ -r "$i" ] && config+=( "$i" ) [[ -r $i ]] && config+=( "$i" )
done done
fi fi
# Known hosts files from configs # Known hosts files from configs
if [ ${#config[@]} -gt 0 ]; then if [[ ${#config[@]} -gt 0 ]]; then
local OIFS=$IFS IFS=$'\n' local OIFS=$IFS IFS=$'\n'
local -a tmpkh local -a tmpkh
# expand paths (if present) to global and user known hosts files # expand paths (if present) to global and user known hosts files
@ -1428,20 +1426,20 @@ _known_hosts_real()
i=${i//\"} i=${i//\"}
# Eval/expand possible `~' or `~user' # Eval/expand possible `~' or `~user'
__expand_tilde_by_ref i __expand_tilde_by_ref i
[ -r "$i" ] && kh+=( "$i" ) [[ -r $i ]] && kh+=( "$i" )
done done
IFS=$OIFS IFS=$OIFS
fi fi
if [ -z "$configfile" ]; then if [[ -z $configfile ]]; then
# Global and user known_hosts files # Global and user known_hosts files
for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \ for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
/etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
~/.ssh/known_hosts2; do ~/.ssh/known_hosts2; do
[ -r "$i" ] && kh+=( "$i" ) [[ -r $i ]] && kh+=( "$i" )
done done
for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
[ -d "$i" ] && khd+=( "$i"/*pub ) [[ -d $i ]] && khd+=( "$i"/*pub )
done done
fi fi
@ -1459,14 +1457,14 @@ _known_hosts_real()
# Digits followed by no dot or colon - search for digits followed # Digits followed by no dot or colon - search for digits followed
# by a dot or a colon # by a dot or a colon
awkcur="^$awkcur.*[.:]" awkcur="^$awkcur.*[.:]"
elif [ -z "$awkcur" ]; then elif [[ -z $awkcur ]]; then
# A blank - search for a dot, a colon, or an alpha character # A blank - search for a dot, a colon, or an alpha character
awkcur="[a-z.:]" awkcur="[a-z.:]"
else else
awkcur="^$awkcur" awkcur="^$awkcur"
fi fi
if [ ${#kh[@]} -gt 0 ]; then if [[ ${#kh[@]} -gt 0 ]]; then
# FS needs to look for a comma separated list # FS needs to look for a comma separated list
COMPREPLY+=( $( awk 'BEGIN {FS=","} COMPREPLY+=( $( awk 'BEGIN {FS=","}
/^\s*[^|\#]/ { /^\s*[^|\#]/ {
@ -1477,7 +1475,7 @@ _known_hosts_real()
if ($i !~ /[*?]/ && $i ~ /'"$awkcur"'/) {print $i} \ if ($i !~ /[*?]/ && $i ~ /'"$awkcur"'/) {print $i} \
}}' "${kh[@]}" 2>/dev/null ) ) }}' "${kh[@]}" 2>/dev/null ) )
fi fi
if [ ${#khd[@]} -gt 0 ]; then if [[ ${#khd[@]} -gt 0 ]]; then
# Needs to look for files called # Needs to look for files called
# .../.ssh2/key_22_<hostname>.pub # .../.ssh2/key_22_<hostname>.pub
# dont fork any processes, because in a cluster environment, # dont fork any processes, because in a cluster environment,
@ -1519,7 +1517,7 @@ _known_hosts_real()
# Add results of normal hostname completion, unless # Add results of normal hostname completion, unless
# `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value. # `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value.
if [ -n "${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1}" ]; then if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then
COMPREPLY+=( COMPREPLY+=(
$( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) ) $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) )
fi fi
@ -1661,7 +1659,7 @@ _command_offset()
fi fi
if [[ -n $cspec ]]; then if [[ -n $cspec ]]; then
if [ "${cspec#* -F }" != "$cspec" ]; then if [[ ${cspec#* -F } != $cspec ]]; then
# complete -F <function> # complete -F <function>
# get function name # get function name
@ -1679,7 +1677,7 @@ _command_offset()
while true; do while true; do
# FIXME: should we take "+o opt" into account? # FIXME: should we take "+o opt" into account?
t=${cspec#*-o } t=${cspec#*-o }
if [ "$t" == "$cspec" ]; then if [[ $t == $cspec ]]; then
break break
fi fi
opt=${t%% *} opt=${t%% *}
@ -1691,7 +1689,7 @@ _command_offset()
cspec=${cspec%%$compcmd} cspec=${cspec%%$compcmd}
COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) ) COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) )
fi fi
elif [ ${#COMPREPLY[@]} -eq 0 ]; then elif [[ ${#COMPREPLY[@]} -eq 0 ]]; then
_minimal _minimal
fi fi
fi fi
@ -1800,12 +1798,12 @@ _filedir_xspec()
toks+=( $( toks+=( $(
eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
while read -r tmp; do while read -r tmp; do
[ -n $tmp ] && printf '%s\n' $tmp [[ -n $tmp ]] && printf '%s\n' $tmp
done done
} }
)) ))
[ ${#toks[@]} -ne 0 ] && compopt -o filenames [[ ${#toks[@]} -ne 0 ]] && compopt -o filenames
COMPREPLY=( "${toks[@]}" ) COMPREPLY=( "${toks[@]}" )
} }

View File

@ -12,7 +12,7 @@ _mock()
local cfgdir=/etc/mock count=0 i local cfgdir=/etc/mock count=0 i
for i in "${words[@]}" ; do for i in "${words[@]}" ; do
[ $count -eq $cword ] && break [[ $count -eq $cword ]] && break
if [[ "$i" == --configdir ]] ; then if [[ "$i" == --configdir ]] ; then
cfgdir="${words[((count+1))]}" cfgdir="${words[((count+1))]}"
elif [[ "$i" == --configdir=* ]] ; then elif [[ "$i" == --configdir=* ]] ; then

View File

@ -49,7 +49,7 @@ _module ()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ] ; then if [[ $cword -eq 1 ]]; then
# First parameter on line -- we expect it to be a mode selection # First parameter on line -- we expect it to be a mode selection
local options local options
@ -58,7 +58,7 @@ _module ()
COMPREPLY=( $(compgen -W "$options" -- "$cur") ) COMPREPLY=( $(compgen -W "$options" -- "$cur") )
elif [ $cword -eq 2 ] ; then elif [[ $cword -eq 2 ]]; then
case $prev in case $prev in
add|display|help|load|show|whatis) add|display|help|load|show|whatis)
COMPREPLY=( $(_module_avail "$cur") ) COMPREPLY=( $(_module_avail "$cur") )
@ -70,7 +70,7 @@ _module ()
COMPREPLY=( $(_module_path "$cur") ) COMPREPLY=( $(_module_path "$cur") )
;; ;;
esac esac
elif [ $cword -eq 3 ] ; then elif [[ $cword -eq 3 ]]; then
case ${words[1]} in case ${words[1]} in
swap|switch) swap|switch)
COMPREPLY=( $(_module_avail "$cur") ) COMPREPLY=( $(_module_avail "$cur") )

View File

@ -45,7 +45,7 @@ _yum()
fi fi
done done
if [ -n "$special" ]; then if [[ -n $special ]]; then
# TODO: install|update|upgrade should not match *src.rpm # TODO: install|update|upgrade should not match *src.rpm
if [[ "$cur" == @(*/|[.~])* && \ if [[ "$cur" == @(*/|[.~])* && \
"$special" == @(deplist|install|update|upgrade) ]]; then "$special" == @(deplist|install|update|upgrade) ]]; then

View File

@ -45,7 +45,7 @@ _ant()
break break
fi fi
done done
[ ! -f $buildfile ] && return 0 [[ ! -f $buildfile ]] && return 0
# parse buildfile for targets # parse buildfile for targets
local line targets local line targets

View File

@ -12,7 +12,7 @@ _apt_build()
fi fi
done done
if [ -n "$special" ]; then if [[ -n $special ]]; then
case $special in case $special in
install|source|info) install|source|info)
COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null ) ) COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null ) )

View File

@ -6,7 +6,7 @@ _apt_cache()
_init_completion || return _init_completion || return
local special i local special i
if [ "$cur" != show ]; then if [[ $cur != show ]]; then
for (( i=0; i < ${#words[@]}-1; i++ )); do for (( i=0; i < ${#words[@]}-1; i++ )); do
if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then
special=${words[i]} special=${words[i]}
@ -15,7 +15,7 @@ _apt_cache()
fi fi
if [ -n "$special" ]; then if [[ -n $special ]]; then
case $special in case $special in
add) add)
_filedir _filedir

View File

@ -12,10 +12,10 @@ _apt_get()
fi fi
done done
if [ -n "$special" ]; then if [[ -n $special ]]; then
case $special in case $special in
remove|autoremove|purge) remove|autoremove|purge)
if [ -f /etc/debian_version ]; then if [[ -f /etc/debian_version ]]; then
# Debian system # Debian system
COMPREPLY=( $( \ COMPREPLY=( $( \
_xfunc dpkg _comp_dpkg_installed_packages $cur ) ) _xfunc dpkg _comp_dpkg_installed_packages $cur ) )

View File

@ -10,7 +10,7 @@ _avctrl()
else else
local args local args
_count_args _count_args
if [ $args -eq 1 ]; then if [[ $args -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) )
fi fi
fi fi

View File

@ -5,7 +5,7 @@ _cardctl()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'status config ident suspend \ COMPREPLY=( $( compgen -W 'status config ident suspend \
resume reset eject insert scheme' -- "$cur" ) ) resume reset eject insert scheme' -- "$cur" ) )
fi fi

View File

@ -31,7 +31,7 @@ _cfrun()
break break
fi fi
done done
[ ! -f $hostfile ] && return 0 [[ ! -f $hostfile ]] && return 0
COMPREPLY=( $(compgen -W "$( command grep -v \ COMPREPLY=( $(compgen -W "$( command grep -v \
-E '(=|^$|^#)' $hostfile )" -- "$cur" ) ) -E '(=|^$|^#)' $hostfile )" -- "$cur" ) )

View File

@ -5,7 +5,7 @@ _cksfv()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
return 0 return 0
fi fi

View File

@ -26,7 +26,7 @@ _configure()
# --option=SETTING will include 'SETTING' as a contextual hint # --option=SETTING will include 'SETTING' as a contextual hint
[[ "$cur" != -* ]] && return 0 [[ "$cur" != -* ]] && return 0
if [ -n "$COMP_CONFIGURE_HINTS" ]; then if [[ -n $COMP_CONFIGURE_HINTS ]]; then
COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
awk '/^ --[A-Za-z]/ { print $1; \ awk '/^ --[A-Za-z]/ { print $1; \
if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \ if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \

View File

@ -33,7 +33,7 @@ _cpio()
$split && return 0 $split && return 0
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \ COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \
-? --help --license --usage --version' -- "$cur" ) ) -? --help --license --usage --version' -- "$cur" ) )
else else

View File

@ -28,7 +28,7 @@ _cryptsetup()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace

View File

@ -13,7 +13,7 @@ _cvs_entries()
_cvs_modules() _cvs_modules()
{ {
if [ -n "$prefix" ]; then if [[ -n $prefix ]]; then
COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) ) COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) )
else else
COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) ) COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) )
@ -39,9 +39,8 @@ _cvs_roots()
{ {
local -a cvsroots local -a cvsroots
cvsroots=( $CVSROOT ) cvsroots=( $CVSROOT )
[ -r ~/.cvspass ] && \ [[ -r ~/.cvspass ]] && cvsroots+=( $( awk '{ print $2 }' ~/.cvspass ) )
cvsroots+=( $( awk '{ print $2 }' ~/.cvspass ) ) [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots < CVS/Root
[ -r CVS/Root ] && mapfile -tO ${#cvsroots[@]} cvsroots < CVS/Root
COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) )
__ltrim_colon_completions "$cur" __ltrim_colon_completions "$cur"
} }
@ -56,12 +55,12 @@ _cvs()
count=0 count=0
for i in "${words[@]}"; do for i in "${words[@]}"; do
[ $count -eq $cword ] && break [[ $count -eq $cword ]] && break
# Last parameter was the CVSROOT, now go back to mode selection # Last parameter was the CVSROOT, now go back to mode selection
if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
mode="" mode=""
fi fi
if [ -z "$mode" ]; then if [[ -z $mode ]]; then
case $i in case $i in
-H|--help) -H|--help)
COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) )
@ -152,7 +151,7 @@ _cvs()
if [[ "$cur" != -* ]]; then if [[ "$cur" != -* ]]; then
_cvs_entries _cvs_entries
[ -z "$cur" ] && files=( !(CVS) ) || \ [[ -z $cur ]] && files=( !(CVS) ) || \
files=( $( command ls -d ${cur}* 2>/dev/null ) ) files=( $( command ls -d ${cur}* 2>/dev/null ) )
local f local f
for i in ${!files[@]}; do for i in ${!files[@]}; do
@ -221,7 +220,7 @@ _cvs()
esac esac
if [[ "$cur" != -* ]]; then if [[ "$cur" != -* ]]; then
[ -z "$cvsroot" ] && cvsroot=$CVSROOT [[ -z $cvsroot ]] && cvsroot=$CVSROOT
COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \ COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \
awk '{print $1}' ) ) awk '{print $1}' ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
@ -244,7 +243,7 @@ _cvs()
# if $COMP_CVS_REMOTE is not null, 'cvs commit' will # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
# complete on remotely checked-out files (requires # complete on remotely checked-out files (requires
# passwordless access to the remote repository # passwordless access to the remote repository
if [ -n "${COMP_CVS_REMOTE:-}" ]; then if [[ -n ${COMP_CVS_REMOTE:-} ]]; then
# this is the least computationally intensive way found so # this is the least computationally intensive way found so
# far, but other changes (something other than # far, but other changes (something other than
# changed/removed/new) may be missing # changed/removed/new) may be missing
@ -298,7 +297,7 @@ _cvs()
esac esac
if [[ "$cur" != -* ]]; then if [[ "$cur" != -* ]]; then
[ -z "$cvsroot" ] && cvsroot=$CVSROOT [[ -z $cvsroot ]] && cvsroot=$CVSROOT
COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) ) COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
else else
@ -318,9 +317,9 @@ _cvs()
if [[ "$cur" != -* ]]; then if [[ "$cur" != -* ]]; then
# starts with same algorithm as checkout # starts with same algorithm as checkout
[ -z "$cvsroot" ] && cvsroot=$CVSROOT [[ -z $cvsroot ]] && cvsroot=$CVSROOT
local prefix=${cur%/*} local prefix=${cur%/*}
if [ -r ${cvsroot}/${prefix} ]; then if [[ -r ${cvsroot}/${prefix} ]]; then
_cvs_modules _cvs_modules
COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) COMPREPLY=( ${COMPREPLY[@]#$cvsroot} )
COMPREPLY=( ${COMPREPLY[@]#\/} ) COMPREPLY=( ${COMPREPLY[@]#\/} )
@ -337,7 +336,7 @@ _cvs()
_cvs_entries _cvs_entries
# find out what files are missing # find out what files are missing
for i in "${entries[@]}"; do for i in "${entries[@]}"; do
[ ! -r "$i" ] && miss+=( $i ) [[ ! -r $i ]] && miss+=( $i )
done done
COMPREPLY=( $( compgen -W '${miss[@]:-}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${miss[@]:-}' -- "$cur" ) )
else else

View File

@ -17,17 +17,17 @@ _dict()
case ${words[i]} in case ${words[i]} in
-h|--host) -h|--host)
host=${words[i+1]} host=${words[i+1]}
[ -n "$host" ] && host="-h $host" [[ -n $host ]] && host="-h $host"
i=$((++i)) i=$((++i))
;; ;;
-p|--port) -p|--port)
port=${words[i+1]} port=${words[i+1]}
[ -n "$port" ] && port="-p $port" [[ -n $port ]] && port="-p $port"
i=$((++i)) i=$((++i))
;; ;;
-d|--database) -d|--database)
db=${words[i+1]} db=${words[i+1]}
[ -n "$db" ] && host="-d $db" [[ -n $db ]] && host="-d $db"
i=$((++i)) i=$((++i))
;; ;;
*) *)
@ -54,7 +54,7 @@ _dict()
esac esac
local dictfile=/usr/share/dict/words local dictfile=/usr/share/dict/words
[ -r $dictfile ] && \ [[ -r $dictfile ]] && \
COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) )
} && } &&
complete -F _dict -o default dict rdict complete -F _dict -o default dict rdict

View File

@ -5,7 +5,7 @@ _e2label()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
cur=${cur:=/dev/} cur=${cur:=/dev/}
_filedir _filedir
fi fi

View File

@ -46,7 +46,7 @@ _feh()
-T|--theme) -T|--theme)
local conf_path=~/.config/feh/themes local conf_path=~/.config/feh/themes
local theme_name theme_opts local theme_name theme_opts
[ -r "$conf_path" ] || return [[ -r $conf_path ]] || return
while read theme_name theme_opts; do while read theme_name theme_opts; do
if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then
continue continue

View File

@ -6,12 +6,12 @@ _function()
_init_completion || return _init_completion || return
if [[ $1 == @(declare|typeset) ]]; then if [[ $1 == @(declare|typeset) ]]; then
if [ "$prev" = -f ]; then if [[ $prev == -f ]]; then
COMPREPLY=( $( compgen -A function -- "$cur" ) ) COMPREPLY=( $( compgen -A function -- "$cur" ) )
elif [[ "$cur" == -* ]]; then elif [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) ) COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) )
fi fi
elif [ $cword -eq 1 ]; then elif [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -A function -- "$cur" ) ) COMPREPLY=( $( compgen -A function -- "$cur" ) )
else else
COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" ) COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" )

View File

@ -5,7 +5,7 @@ _gdb()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
local IFS local IFS
compopt -o filenames compopt -o filenames
if [[ "$cur" == */* ]]; then if [[ "$cur" == */* ]]; then
@ -24,7 +24,7 @@ _gdb()
-mindepth 1 -maxdepth 1 -not -type d -executable \ -mindepth 1 -maxdepth 1 -not -type d -executable \
-printf "%f\\n" 2>/dev/null)' -- "$cur" ) ) -printf "%f\\n" 2>/dev/null)' -- "$cur" ) )
fi fi
elif [ $cword -eq 2 ]; then elif [[ $cword -eq 2 ]]; then
COMPREPLY=( $( compgen -W "$( command ps axo comm,pid | \ COMPREPLY=( $( compgen -W "$( command ps axo comm,pid | \
awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}' )" -- "$cur" ) ) awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}' )" -- "$cur" ) )
compopt -o filenames compopt -o filenames

View File

@ -20,7 +20,7 @@ _gpg()
-r|--recipient) -r|--recipient)
COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )) sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
if [ -e ~/.gnupg/gpg.conf ]; then if [[ -e ~/.gnupg/gpg.conf ]]; then
COMPREPLY+=( $( compgen -W "$( sed -ne \ COMPREPLY+=( $( compgen -W "$( sed -ne \
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
~/.gnupg/gpg.conf )" -- "$cur") ) ~/.gnupg/gpg.conf )" -- "$cur") )

View File

@ -24,7 +24,7 @@ _gpg2()
-r|--recipient) -r|--recipient)
COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \
sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )) sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ))
if [ -e ~/.gnupg/gpg.conf ]; then if [[ -e ~/.gnupg/gpg.conf ]]; then
COMPREPLY+=( $( compgen -W "$( sed -ne \ COMPREPLY+=( $( compgen -W "$( sed -ne \
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
~/.gnupg/gpg.conf)" -- "$cur")) ~/.gnupg/gpg.conf)" -- "$cur"))

View File

@ -2,7 +2,7 @@
_bluetooth_adresses() _bluetooth_adresses()
{ {
if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then
COMPREPLY+=( $( compgen -W "$( hcitool scan | \ COMPREPLY+=( $( compgen -W "$( hcitool scan | \
awk '/^\t/{print $1}' )" -- "$cur" ) ) awk '/^\t/{print $1}' )" -- "$cur" ) )
fi fi
@ -51,7 +51,7 @@ _hcitool()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else else
@ -63,7 +63,7 @@ _hcitool()
case $arg in case $arg in
name|info|dc|rssi|lq|afh|auth|key|clkoff|lst) name|info|dc|rssi|lq|afh|auth|key|clkoff|lst)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
fi fi
;; ;;
@ -72,14 +72,14 @@ _hcitool()
COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) )
else else
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
fi fi
fi fi
;; ;;
sr) sr)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
else else
COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) )
@ -87,7 +87,7 @@ _hcitool()
;; ;;
cpt) cpt)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
else else
_bluetooth_packet_types _bluetooth_packet_types
@ -95,7 +95,7 @@ _hcitool()
;; ;;
tpl|enc|clock) tpl|enc|clock)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
else else
COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
@ -122,7 +122,7 @@ _sdptool()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else else
@ -206,7 +206,7 @@ _rfcomm()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else else
@ -215,12 +215,12 @@ _rfcomm()
fi fi
else else
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_devices _bluetooth_devices
else else
case $arg in case $arg in
connect|bind) connect|bind)
if [ $args -eq 3 ]; then if [[ $args -eq 3 ]]; then
_bluetooth_adresses _bluetooth_adresses
fi fi
;; ;;
@ -245,7 +245,7 @@ _ciptool()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
else else
@ -256,7 +256,7 @@ _ciptool()
case $arg in case $arg in
connect|release|loopback) connect|release|loopback)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
fi fi
;; ;;
@ -302,7 +302,7 @@ _hciconfig()
local arg local arg
_get_first_arg _get_first_arg
if [ -z $arg ]; then if [[ -z $arg ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) )
else else
@ -318,20 +318,20 @@ _hciconfig()
case $arg in case $arg in
putkey|delkey) putkey|delkey)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_adresses _bluetooth_adresses
fi fi
;; ;;
lm) lm)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
COMPREPLY=( $( compgen -W 'MASTER \ COMPREPLY=( $( compgen -W 'MASTER \
SLAVE NONE ACCEPT' -- "$cur" ) ) SLAVE NONE ACCEPT' -- "$cur" ) )
fi fi
;; ;;
ptype) ptype)
_count_args _count_args
if [ $args -eq 2 ]; then if [[ $args -eq 2 ]]; then
_bluetooth_packet_types _bluetooth_packet_types
fi fi
;; ;;

View File

@ -7,7 +7,7 @@ _ifupdown()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
_configured_interfaces _configured_interfaces
COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
fi fi

View File

@ -45,12 +45,12 @@ _info()
if [[ $INFOPATH == *: ]]; then if [[ $INFOPATH == *: ]]; then
infopath=${INFOPATH}${infopath} infopath=${INFOPATH}${infopath}
elif [ ${INFOPATH:+set} ]; then elif [[ ${INFOPATH:+set} ]]; then
infopath=$INFOPATH infopath=$INFOPATH
fi fi
infopath=$infopath: infopath=$infopath:
if [ -n "$cur" ]; then if [[ -n $cur ]]; then
infopath="${infopath//://$cur* }" infopath="${infopath//://$cur* }"
else else
infopath="${infopath//:// }" infopath="${infopath//:// }"
@ -62,9 +62,7 @@ _info()
COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
# weed out info dir file # weed out info dir file
for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
if [ "${COMPREPLY[$i]}" == 'dir' ]; then [[ ${COMPREPLY[$i]} == dir ]] && unset COMPREPLY[$i]
unset COMPREPLY[$i]
fi
done done
# strip suffix from info pages # strip suffix from info pages
COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} )

View File

@ -9,8 +9,8 @@ _invoke_rc_d()
local sysvdir services options valid_options local sysvdir services options valid_options
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \
|| sysvdir=/etc/init.d || sysvdir=/etc/init.d
services=( $( printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob) ) ) services=( $( printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob) ) )
services=( ${services[@]#$sysvdir/} ) services=( ${services[@]#$sysvdir/} )
@ -24,7 +24,7 @@ _invoke_rc_d()
| sort | uniq -u \ | sort | uniq -u \
) ) ) )
COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) )
elif [ -x $sysvdir/$prev ]; then elif [[ -x $sysvdir/$prev ]]; then
COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
-ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
$sysvdir/$prev`' -- "$cur" ) ) $sysvdir/$prev`' -- "$cur" ) )

View File

@ -71,11 +71,11 @@ _ipmitool()
for (( i=1; i < ${#words[@]}-1; i++ )); do for (( i=1; i < ${#words[@]}-1; i++ )); do
[[ -n $cmd ]] && subcmd=${words[i]} && break [[ -n $cmd ]] && subcmd=${words[i]} && break
for c in ${cmds[@]}; do for c in ${cmds[@]}; do
[ ${words[i]} = $c ] && cmd=$c && break [[ ${words[i]} == $c ]] && cmd=$c && break
done done
done done
if [ -z "$cmd" ]; then if [[ -z $cmd ]]; then
COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) )
return 0 return 0
fi fi
@ -100,11 +100,11 @@ _ipmitool()
print|set) print|set)
;; ;;
alert) alert)
[ "$prev" = alert ] && \ [[ $prev == alert ]] && \
COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) )
;; ;;
stats) stats)
[ "$prev" = stats ] && \ [[ $prev == stats ]] && \
COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) )
;; ;;
*) *)
@ -161,7 +161,7 @@ _ipmitool()
_filedir _filedir
;; ;;
time) time)
[ "$prev" = time ] && \ [[ $prev == time ]] && \
COMPREPLY=( $( compgen -W 'get set' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'get set' -- "$cur" ) )
;; ;;
*) *)
@ -176,7 +176,7 @@ _ipmitool()
summary|list|disable|enable|priv|test) summary|list|disable|enable|priv|test)
;; ;;
set) set)
[ "$prev" = set ] && \ [[ $prev == set ]] && \
COMPREPLY=( $( compgen -W 'name password' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'name password' -- "$cur" ) )
;; ;;
*) *)
@ -187,7 +187,7 @@ _ipmitool()
;; ;;
set) set)
[ "$prev" = set ] && \ [[ $prev == set ]] && \
COMPREPLY=( $( compgen -W 'hostname username password privlvl COMPREPLY=( $( compgen -W 'hostname username password privlvl
authtype localaddr targetaddr port csv verbose' \ authtype localaddr targetaddr port csv verbose' \
-- "$cur" ) ) -- "$cur" ) )

View File

@ -18,7 +18,7 @@ _ipsec_freeswan()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \ COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \
pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \ pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \
tncfg whack' -- "$cur" ) ) tncfg whack' -- "$cur" ) )
@ -55,7 +55,7 @@ _ipsec_strongswan()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'down irdumm leases listaacerts listacerts \ COMPREPLY=( $( compgen -W 'down irdumm leases listaacerts listacerts \
listalgs listall listcacerts listcainfos listcards listcerts \ listalgs listall listcacerts listcainfos listcards listcerts \
listcrls listgroups listocsp listocspcerts listpubkeys openac pki listcrls listgroups listocsp listocspcerts listpubkeys openac pki

View File

@ -29,12 +29,12 @@ _iptables()
`iptables $table -nL | sed -ne "$chain" \ `iptables $table -nL | sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
"$cur" ) ) "$cur" ) )
elif [ "$table" = "-t nat" ]; then elif [[ $table == "-t nat" ]]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
-- "$cur" ) ) -- "$cur" ) )
elif [ "$table" = "-t mangle" ]; then elif [[ $table == "-t mangle" ]]; then
COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
MARK TOS `iptables $table -nL | sed -ne "$chain" \ MARK TOS `iptables $table -nL | sed -ne "$chain" \
-e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \

View File

@ -6,7 +6,7 @@ _isql()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
[ -f "$ODBCINI" ] \ [[ -f $ODBCINI ]] \
&& COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) ) && COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) )
} && } &&
complete -F _isql isql complete -F _isql isql

View File

@ -13,7 +13,7 @@ _iwconfig()
;; ;;
essid) essid)
COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then
COMPREPLY+=( $( compgen -W \ COMPREPLY+=( $( compgen -W \
"$( iwlist ${words[1]} scan | \ "$( iwlist ${words[1]} scan | \
awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) ) awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) )
@ -37,7 +37,7 @@ _iwconfig()
;; ;;
ap) ap)
COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) )
if [ -n "${COMP_IWLIST_SCAN:-}" ]; then if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then
COMPREPLY+=( $( compgen -W \ COMPREPLY+=( $( compgen -W \
"$( iwlist ${words[1]} scan | \ "$( iwlist ${words[1]} scan | \
awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) ) awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) )
@ -73,7 +73,7 @@ _iwconfig()
;; ;;
esac esac
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
else else

View File

@ -5,7 +5,7 @@ _iwlist()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
else else

View File

@ -16,7 +16,7 @@ _iwpriv()
;; ;;
esac esac
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
else else

View File

@ -5,7 +5,7 @@ _iwspy()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) )
else else

View File

@ -21,10 +21,10 @@ _java_find_classpath()
done done
# default to environment # default to environment
[ -z "$classpath" ] && classpath=$CLASSPATH [[ -z $classpath ]] && classpath=$CLASSPATH
# default to current directory # default to current directory
[ -z "$classpath" ] && classpath=. [[ -z $classpath ]] && classpath=.
} }
# exact sourcepath determination # exact sourcepath determination
@ -41,7 +41,7 @@ _java_find_sourcepath()
done done
# default to classpath # default to classpath
if [ -z "$sourcepath" ]; then if [[ -z $sourcepath ]]; then
local classpath local classpath
_java_find_classpath _java_find_classpath
sourcepath=$classpath sourcepath=$classpath
@ -69,7 +69,7 @@ _java_classes()
command grep '^[^$]*\.class$' ) ) command grep '^[^$]*\.class$' ) )
fi fi
elif [ -d $i ]; then elif [[ -d $i ]]; then
COMPREPLY+=( COMPREPLY+=(
$( compgen -d -- "$i/$cur" | sed -e "s|^$i/\(.*\)|\1.|" ) $( compgen -d -- "$i/$cur" | sed -e "s|^$i/\(.*\)|\1.|" )
$( compgen -f -X '!*.class' -- "$i/$cur" | \ $( compgen -f -X '!*.class' -- "$i/$cur" | \
@ -101,7 +101,7 @@ _java_packages()
cur=${cur//.//} cur=${cur//.//}
# parse each sourcepath element for packages # parse each sourcepath element for packages
for i in ${sourcepath//:/ }; do for i in ${sourcepath//:/ }; do
if [ -d $i ]; then if [[ -d $i ]]; then
COMPREPLY+=( $( command ls -F -d $i/$cur* 2>/dev/null | \ COMPREPLY+=( $( command ls -F -d $i/$cur* 2>/dev/null | \
sed -e 's|^'$i'/||' ) ) sed -e 's|^'$i'/||' ) )
fi fi

View File

@ -8,7 +8,7 @@ _kldload()
_init_completion || return _init_completion || return
local moddir=/modules/ local moddir=/modules/
[ -d $moddir ] || moddir=/boot/kernel/ [[ -d $moddir ]] || moddir=/boot/kernel/
compopt -o filenames compopt -o filenames
COMPREPLY=( $( compgen -f "$moddir$cur" ) ) COMPREPLY=( $( compgen -f "$moddir$cur" ) )

View File

@ -18,7 +18,7 @@ _links()
-source -version -help' -- "$cur" ) ) -source -version -help' -- "$cur" ) )
;; ;;
*) *)
if [ -r ~/.links/links.his ]; then if [[ -r ~/.links/links.his ]]; then
COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \ COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \
-- "$cur" ) ) -- "$cur" ) )
fi fi

View File

@ -314,7 +314,7 @@ _vgcreate()
--verbose --version' -- "$cur" ) ) --verbose --version' -- "$cur" ) )
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_volumegroups _volumegroups
else else
_physicalvolumes _physicalvolumes
@ -373,7 +373,7 @@ _vgreduce()
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_volumegroups _volumegroups
else else
_physicalvolumes _physicalvolumes
@ -402,7 +402,7 @@ _vgextend()
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_volumegroups _volumegroups
else else
_physicalvolumes _physicalvolumes
@ -686,7 +686,7 @@ _lvcreate()
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_volumegroups _volumegroups
else else
_physicalvolumes _physicalvolumes
@ -779,7 +779,7 @@ _lvresize()
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_logicalvolumes _logicalvolumes
else else
_physicalvolumes _physicalvolumes
@ -808,7 +808,7 @@ _lvextend()
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) )
else else
_args _args
if [ $args -eq 0 ]; then if [[ $args -eq 0 ]]; then
_logicalvolumes _logicalvolumes
else else
_physicalvolumes _physicalvolumes
@ -822,7 +822,7 @@ _lvm()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \ COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \
lvcreate lvdisplay lvextend lvmchange \ lvcreate lvdisplay lvextend lvmchange \
lvmdiskscan lvmsadc lvmsar lvreduce \ lvmdiskscan lvmsadc lvmsar lvreduce \

View File

@ -58,8 +58,8 @@ _make()
fi fi
done done
[ -n "$makef" ] && makef="-f ${makef}" [[ -n $makef ]] && makef="-f ${makef}"
[ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}" [[ -n $makef_dir ]] && makef_dir="-C ${makef_dir}"
COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \ COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \
awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \

View File

@ -63,7 +63,7 @@ _man()
manpath=$MANPATH manpath=$MANPATH
fi fi
if [ -z "$manpath" ]; then if [[ -z $manpath ]]; then
COMPREPLY=( $( compgen -c -- "$cur" ) ) COMPREPLY=( $( compgen -c -- "$cur" ) )
return 0 return 0
fi fi
@ -72,7 +72,7 @@ _man()
[[ "$prev" == $mansect ]] && sect=$prev || sect='*' [[ "$prev" == $mansect ]] && sect=$prev || sect='*'
manpath=$manpath: manpath=$manpath:
if [ -n "$cur" ]; then if [[ -n $cur ]]; then
manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }" manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
else else
manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }" manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"

View File

@ -29,11 +29,10 @@ _minicom()
return 0 return 0
else else
local confdir local confdir
[ -n "$( command ls /etc/minirc.* 2>/dev/null)" ] \ [[ -n $( command ls /etc/minirc.* 2>/dev/null ) ]] && confdir=/etc
&& confdir=/etc [[ -n $( command ls /etc/minicom/minirc.* 2>/dev/null ) ]] \
[ -n "$( command ls /etc/minicom/minirc.* 2>/dev/null)" ] \
&& confdir=/etc/minicom && confdir=/etc/minicom
if [ -n "$confdir" ]; then if [[ -n $confdir ]]; then
COMPREPLY=( $( compgen -W '$( printf "%s\n" $confdir/minirc.* | \ COMPREPLY=( $( compgen -W '$( printf "%s\n" $confdir/minirc.* | \
sed -e "s|$confdir/minirc.||")' -- "$cur" ) ) sed -e "s|$confdir/minirc.||")' -- "$cur" ) )
return 0 return 0

View File

@ -92,7 +92,7 @@ _mount()
if [[ "$cur" == *:* ]]; then if [[ "$cur" == *:* ]]; then
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[ -x "$sm" ] || continue [[ -x $sm ]] || continue
COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \
awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
return 0 return 0
@ -102,24 +102,24 @@ _mount()
if [[ "$cur" == //* ]]; then if [[ "$cur" == //* ]]; then
host=${cur#//} host=${cur#//}
host=${host%%/*} host=${host%%/*}
if [ -n "$host" ]; then if [[ -n $host ]]; then
COMPREPLY=( $( compgen -P "//$host" -W \ COMPREPLY=( $( compgen -P "//$host" -W \
"$( smbclient -d 0 -NL $host 2>/dev/null | "$( smbclient -d 0 -NL $host 2>/dev/null |
sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \ sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \
-- "${cur#//$host}" ) ) -- "${cur#//$host}" ) )
fi fi
elif [ -r /etc/vfstab ]; then elif [[ -r /etc/vfstab ]]; then
# Solaris # Solaris
COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) )
elif [ ! -e /etc/fstab ]; then elif [[ ! -e /etc/fstab ]]; then
# probably Cygwin # probably Cygwin
COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) )
else else
# probably Linux # probably Linux
if [ "$prev" = -L ]; then if [[ $prev == -L ]]; then
_linux_fstab -L < /etc/fstab _linux_fstab -L < /etc/fstab
elif [ "$prev" = -U ]; then elif [[ $prev == -U ]]; then
COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- "$cur" ) )
else else
_linux_fstab < /etc/fstab _linux_fstab < /etc/fstab

View File

@ -30,7 +30,7 @@ _mplayer()
return 0 return 0
;; ;;
-font|-subfont) -font|-subfont)
if [ "$prev" = -font ]; then if [[ $prev == -font ]]; then
_filedir '@(desc|ttf)' _filedir '@(desc|ttf)'
else else
_filedir ttf _filedir ttf
@ -67,7 +67,7 @@ _mplayer()
# if you don't have installed mplayer in /usr you # if you don't have installed mplayer in /usr you
# may want to set the MPLAYER_SKINS_DIR global variable # may want to set the MPLAYER_SKINS_DIR global variable
local -a dirs local -a dirs
if [ -n "$MPLAYER_SKINS_DIR" ]; then if [[ -n $MPLAYER_SKINS_DIR ]]; then
dirs=($MPLAYER_SKINS_DIR) dirs=($MPLAYER_SKINS_DIR)
else else
dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins) dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins)

View File

@ -20,7 +20,7 @@ _mtx()
drives=${drives//:Full} drives=${drives//:Full}
drives=${drives//:Empty} drives=${drives//:Empty}
if [ $cword -gt 1 ]; then if [[ $cword -gt 1 ]]; then
case $prev in case $prev in
load) load)
COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) )

View File

@ -21,23 +21,23 @@ _muttrc()
{ {
# Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument
set -- "${words[@]}" set -- "${words[@]}"
while [ $# -gt 0 ]; do while [[ $# -gt 0 ]]; do
if [[ $1 == -F* ]]; then if [[ $1 == -F* ]]; then
if [ ${#1} -gt 2 ]; then if [[ ${#1} -gt 2 ]]; then
muttrc="$(dequote "${1:2}")" muttrc="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && muttrc="$(dequote "$1")" [[ $1 ]] && muttrc="$(dequote "$1")"
fi fi
break break
fi fi
shift shift
done done
if [ -z "$muttrc" ]; then if [[ -z $muttrc ]]; then
if [ -f ~/.${muttcmd}rc ]; then if [[ -f ~/.${muttcmd}rc ]]; then
muttrc="~/.${muttcmd}rc" muttrc="~/.${muttcmd}rc"
elif [ -f ~/.${muttcmd}/${muttcmd}rc ]; then elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then
muttrc="~/.${muttcmd}/${muttcmd}rc" muttrc="~/.${muttcmd}/${muttcmd}rc"
fi fi
fi fi
@ -77,7 +77,7 @@ _muttaliases()
local -a conffiles aliases local -a conffiles aliases
muttrc=$(_muttrc) muttrc=$(_muttrc)
[ -z "$muttrc" ] && return 0 [[ -z $muttrc ]] && return 0
conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
@ -125,10 +125,10 @@ _muttfiledir()
COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) ) COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) )
COMPREPLY=( ${COMPREPLY[@]#$folder/} ) COMPREPLY=( ${COMPREPLY[@]#$folder/} )
return 0 return 0
elif [ "$cur" == !* ]; then elif [[ $cur == !* ]]; then
spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ 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
_filedir _filedir

View File

@ -20,7 +20,7 @@ _mysql()
return 0 return 0
;; ;;
--default-character-set) --default-character-set)
[ -d /usr/share/mysql/charsets ] && \ [[ -d /usr/share/mysql/charsets ]] && \
COMPREPLY=( $( compgen -W "$(command ls /usr/share/mysql/charsets|sed -e '/^\(README\|Index\.xml\)$/d' -e 's/.xml$//') utf8" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$(command ls /usr/share/mysql/charsets|sed -e '/^\(README\|Index\.xml\)$/d' -e 's/.xml$//') utf8" -- "$cur" ) )
return 0 return 0
;; ;;

View File

@ -13,14 +13,14 @@ _openssl_sections()
done done
# if no config given, check some usual default locations # if no config given, check some usual default locations
if [ -z "$config" ]; then if [[ -z $config ]]; then
for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \ for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
/usr/share/ssl/openssl.cnf; do /usr/share/ssl/openssl.cnf; do
[ -f $f ] && config=$f && break [[ -f $f ]] && config=$f && break
done done
fi fi
[ ! -f "$config" ] && return 0 [[ ! -f $config ]] && return 0
COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \ COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \
-- "$cur" ) ) -- "$cur" ) )
@ -48,7 +48,7 @@ _openssl()
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \
rc4-40' rc4-40'
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
else else
command=${words[1]} command=${words[1]}

View File

@ -14,9 +14,9 @@ _p4()
uresource uxbinary xbinary xltext xtempobj xtext \ uresource uxbinary xbinary xltext xtempobj xtext \
text binary resource" text binary resource"
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) )
elif [ $cword -eq 2 ]; then elif [[ $cword -eq 2 ]]; then
case $prev in case $prev in
help) help)
COMPREPLY=( $( compgen -W "simple commands \ COMPREPLY=( $( compgen -W "simple commands \
@ -29,7 +29,7 @@ _p4()
*) *)
;; ;;
esac esac
elif [ $cword -gt 2 ]; then elif [[ $cword -gt 2 ]]; then
case $prev in case $prev in
-t) -t)
case ${words[$cword-2]} in case ${words[$cword-2]} in

View File

@ -40,7 +40,7 @@ _povray()
*.ini\[|*.ini\[*[^]]) # sections in .ini files *.ini\[|*.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}" cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename pfx="${povcur%\["$cur"}" # prefix == filename
[ -r "$pfx" ] || return 0 [[ -r $pfx ]] || return 0
COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
-e 't' -e 'd' -- "$pfx") ) -e 't' -e 'd' -- "$pfx") )
# to prevent [bar] expand to nothing. can be done more easily? # to prevent [bar] expand to nothing. can be done more easily?

View File

@ -13,7 +13,7 @@ _pg_users()
# -w was introduced in 8.4, https://launchpad.net/bugs/164772 # -w was introduced in 8.4, https://launchpad.net/bugs/164772
COMPREPLY=( $( compgen -W "$( psql -Atqwc 'select usename from pg_user' \ COMPREPLY=( $( compgen -W "$( psql -Atqwc 'select usename from pg_user' \
template1 2>/dev/null )" -- "$cur" ) ) template1 2>/dev/null )" -- "$cur" ) )
[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- "$cur" ) ) [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) )
} }
# createdb(1) completion # createdb(1) completion

View File

@ -2,7 +2,7 @@
_puppet_logdest() _puppet_logdest()
{ {
if [ -z "$cur" ]; then if [[ -z $cur ]]; then
COMPREPLY=( $( compgen -W 'syslog console /' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'syslog console /' -- "$cur" ) )
else else
COMPREPLY=( $( compgen -W 'syslog console' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'syslog console' -- "$cur" ) )

View File

@ -5,7 +5,7 @@ _qdbus()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
[ -n "$cur" ] && unset words[${#words[@]}-1] [[ -n $cur ]] && unset words[${#words[@]}-1]
COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \ COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \
sed s/\(.*\)// )' -- "$cur" ) ) sed s/\(.*\)// )' -- "$cur" ) )
} && } &&

View File

@ -11,7 +11,7 @@ _rcs()
dir=${cur%/*} dir=${cur%/*}
# deal with relative directory # deal with relative directory
[ "$file" = "$dir" ] && dir=. [[ $file == $dir ]] && dir=.
COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) ) COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) )

View File

@ -5,10 +5,10 @@ ri_get_methods()
{ {
local regex local regex
if [ "$ri_version" = integrated ]; then if [[ $ri_version == integrated ]]; then
if [ -z "$separator" ]; then if [[ -z $separator ]]; then
regex="(Instance|Class)" regex="(Instance|Class)"
elif [ "$separator" = "#" ]; then elif [[ $separator == "#" ]]; then
regex=Instance regex=Instance
else else
regex=Class regex=Class
@ -45,7 +45,7 @@ _ri()
# -W0 is required here to stop warnings from older versions of ri # -W0 is required here to stop warnings from older versions of ri
# from being captured when used with Ruby 1.8.1 and later # from being captured when used with Ruby 1.8.1 and later
ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated
[ "$ri_version" != "${ri_version%200*}" ] && ri_version=integrated [[ $ri_version != ${ri_version%200*} ]] && ri_version=integrated
# need to also split on commas # need to also split on commas
IFS=$', \n\t' IFS=$', \n\t'
@ -60,11 +60,11 @@ _ri()
return 0 return 0
fi fi
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 2>/dev/null | 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' 2>/dev/null ) ) 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 \
if /^ .*[A-Z]/ then print; end; end' )) if /^ .*[A-Z]/ then print; end; end' ))

View File

@ -7,7 +7,7 @@ _route()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ "$prev" = dev ]; then if [[ $prev == dev ]]; then
_available_interfaces _available_interfaces
return 0 return 0
fi fi
@ -18,7 +18,7 @@ _route()
dyn reinstate dev default gw; do dyn reinstate dev default gw; do
found=false found=false
for (( i=1; i < ${#words[@]}-1; i++ )); do for (( i=1; i < ${#words[@]}-1; i++ )); do
[ "${words[i]}" = "$opt" ] && found=true && break [[ ${words[i]} == $opt ]] && found=true && break
done done
$found || COMPREPLY[${#COMPREPLY[@]}]="$opt" $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
done done

View File

@ -11,7 +11,7 @@ _rpcdebug_flags()
fi fi
done done
if [ -n "$module" ]; then if [[ -n $module ]]; then
COMPREPLY=( $( compgen -W "$( rpcdebug -vh 2>&1 | \ COMPREPLY=( $( compgen -W "$( rpcdebug -vh 2>&1 | \
sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) ) sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) )
fi fi

View File

@ -48,7 +48,7 @@ _rpm()
local cur prev words cword split local cur prev words cword split
_init_completion -s || return _init_completion -s || return
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
# first parameter on line # first parameter on line
case $cur in case $cur in
--*) --*)

View File

@ -5,7 +5,7 @@ _rrdtool ()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [ ${#words[@]} -eq 2 ]; then if [[ ${#words[@]} -eq 2 ]]; then
COMPREPLY=( $( compgen -W 'create update updatev graph dump restore \ COMPREPLY=( $( compgen -W 'create update updatev graph dump restore \
last lastupdate first info fetch tune resize xport' -- "$cur" ) ) last lastupdate first info fetch tune resize xport' -- "$cur" ) )
else else

View File

@ -74,7 +74,7 @@ _rsync()
break break
fi fi
done done
[ "$shell" = ssh ] && _xfunc ssh _scp_remote_files [[ $shell == ssh ]] && _xfunc ssh _scp_remote_files
;; ;;
*) *)
_known_hosts_real -c -a "$cur" _known_hosts_real -c -a "$cur"

View File

@ -45,7 +45,7 @@ _sbopkg()
fi fi
done done
if [ ! -r "$config" ]; then if [[ ! -r $config ]]; then
return 0 return 0
fi fi
@ -63,7 +63,7 @@ _sbopkg()
esac esac
done done
if [ ! -r "$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT" ]; then if [[ ! -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]]; then
return 0 return 0
fi fi
COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\

View File

@ -40,7 +40,7 @@ _sitecopy()
;; ;;
esac esac
if [ -r ~/.sitecopyrc ]; then if [[ -r ~/.sitecopyrc ]]; then
COMPREPLY=( $( compgen -W "$($1 -v | \ COMPREPLY=( $( compgen -W "$($1 -v | \
command sed -n '/^Site:/s/Site: //p')" -- "$cur" ) ) command sed -n '/^Site:/s/Site: //p')" -- "$cur" ) )
fi fi

View File

@ -43,7 +43,7 @@ _slackpkg()
local confdir="/etc/slackpkg" local confdir="/etc/slackpkg"
local config="$confdir/slackpkg.conf" local config="$confdir/slackpkg.conf"
if [ ! -r "$config" ]; then if [[ ! -r $config ]]; then
return 0 return 0
fi fi
. "$config" . "$config"
@ -62,7 +62,7 @@ _slackpkg()
return 0 return 0
;; ;;
install-template|remove-template) install-template|remove-template)
if [ -e "$confdir/templates" ]; then if [[ -e $confdir/templates ]]; then
COMPREPLY=( $( cd "$confdir/templates"; \ COMPREPLY=( $( cd "$confdir/templates"; \
compgen -f -X "!*.template" -- "$cur" ) ) compgen -f -X "!*.template" -- "$cur" ) )
COMPREPLY=( ${COMPREPLY[@]%.template} ) COMPREPLY=( ${COMPREPLY[@]%.template} )

View File

@ -48,7 +48,7 @@ _slapt_get()
break break
fi fi
done done
if [ ! -r "$config" ]; then if [[ ! -r $config ]]; then
return return
fi fi

View File

@ -30,7 +30,7 @@ _slapt_src()
break break
fi fi
done done
if [ "$t" != "all" ]; then if [[ $t != all ]]; then
return 0 return 0
fi fi
@ -42,7 +42,7 @@ _slapt_src()
break break
fi fi
done done
if [ ! -r "$config" ]; then if [[ ! -r $config ]]; then
return 0 return 0
fi fi

View File

@ -7,14 +7,14 @@ _samba_resolve_order()
_samba_domains() _samba_domains()
{ {
if [ -n "${COMP_SAMBA_SCAN:-}" ]; then if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- "$cur" ) )
fi fi
} }
_samba_hosts() _samba_hosts()
{ {
if [ -n "${COMP_SAMBA_SCAN:-}" ]; then if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
COMPREPLY=( $( compgen -W "$( smbtree -N -S | \ COMPREPLY=( $( compgen -W "$( smbtree -N -S | \
sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \
)" -- $cur ) ) )" -- $cur ) )

View File

@ -157,20 +157,20 @@ _ssh()
else else
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${words[@]}" set -- "${words[@]}"
while [ $# -gt 0 ]; do while [[ $# -gt 0 ]]; do
if [[ $1 == -F* ]]; then if [[ $1 == -F* ]]; then
if [ ${#1} -gt 2 ]; then if [[ ${#1} -gt 2 ]]; then
configfile="$(dequote "${1:2}")" configfile="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && configfile="$(dequote "$1")" [[ $1 ]] && configfile="$(dequote "$1")"
fi fi
break break
fi fi
shift shift
done done
_known_hosts_real -a -F "$configfile" "$cur" _known_hosts_real -a -F "$configfile" "$cur"
if [ $cword -ne 1 ]; then if [[ $cword -ne 1 ]]; then
compopt -o filenames compopt -o filenames
COMPREPLY+=( $( compgen -c -- "$cur" ) ) COMPREPLY+=( $( compgen -c -- "$cur" ) )
fi fi
@ -220,13 +220,13 @@ _sftp()
else else
# Search COMP_WORDS for '-F configfile' argument # Search COMP_WORDS for '-F configfile' argument
set -- "${words[@]}" set -- "${words[@]}"
while [ $# -gt 0 ]; do while [[ $# -gt 0 ]]; do
if [[ $1 == -F* ]]; then if [[ $1 == -F* ]]; then
if [ ${#1} -gt 2 ]; then if [[ ${#1} -gt 2 ]]; then
configfile="$(dequote "${1:2}")" configfile="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && configfile="$(dequote "$1")" [[ $1 ]] && configfile="$(dequote "$1")"
fi fi
break break
fi fi
@ -258,12 +258,12 @@ _scp_remote_files()
path=$( sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" ) path=$( sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" )
# default to home dir of specified user on remote host # default to home dir of specified user on remote host
if [ -z "$path" ]; then if [[ -z $path ]]; then
path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null) path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
fi fi
local files local files
if [ "$1" = -d ] ; then if [[ $1 == -d ]]; then
# escape problematic characters; remove non-dirs # escape problematic characters; remove non-dirs
files=$( ssh -o 'Batchmode yes' $userhost \ files=$( ssh -o 'Batchmode yes' $userhost \
command ls -aF1d "$path*" 2>/dev/null | \ command ls -aF1d "$path*" 2>/dev/null | \
@ -288,7 +288,7 @@ _scp_local_files()
local IFS=$'\n' local IFS=$'\n'
local dirsonly=false local dirsonly=false
if [ "$1" = -d ]; then if [[ $1 == -d ]]; then
dirsonly=true dirsonly=true
shift shift
fi fi
@ -350,13 +350,13 @@ _scp()
else else
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
set -- "${words[@]}" set -- "${words[@]}"
while [ $# -gt 0 ]; do while [[ $# -gt 0 ]]; do
if [[ $1 == -F* ]]; then if [[ $1 == -F* ]]; then
if [ ${#1} -gt 2 ]; then if [[ ${#1} -gt 2 ]]; then
configfile="$(dequote "${1:2}")" configfile="$(dequote "${1:2}")"
else else
shift shift
[ "$1" ] && configfile="$(dequote "$1")" [[ $1 ]] && configfile="$(dequote "$1")"
fi fi
break break
fi fi

View File

@ -21,7 +21,7 @@ _strace()
break break
done done
if [ $offset -gt 0 ]; then if [[ $offset -gt 0 ]]; then
_command_offset $offset _command_offset $offset
else else

View File

@ -7,7 +7,7 @@ _tar()
local ext regex tar untar local ext regex tar untar
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'c t x u r d A' -- "$cur" ) )
return 0 return 0
fi fi

View File

@ -5,10 +5,10 @@ _unace()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]] ; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) ) COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) )
else else
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) )
else else
_filedir ace _filedir ace

View File

@ -5,12 +5,12 @@ _unrar()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]] ; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \ COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \
-dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta \ -dh -ep -f -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta \
-tb -tn -to -u -v -ver -vp -x -x@ -y' -- "$cur" ) ) -tb -tn -to -u -v -ver -vp -x -x@ -y' -- "$cur" ) )
else else
if [ $cword -eq 1 ]; then if [[ $cword -eq 1 ]]; then
COMPREPLY=( $( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'e l lb lt p t v vb vt x' -- "$cur" ) )
else else
_filedir rar _filedir rar

View File

@ -5,7 +5,7 @@ _installed_alternatives()
local admindir local admindir
# find the admin dir # find the admin dir
for i in alternatives dpkg/alternatives rpm/alternatives; do for i in alternatives dpkg/alternatives rpm/alternatives; do
[ -d /var/lib/$i ] && admindir=/var/lib/$i && break [[ -d /var/lib/$i ]] && admindir=/var/lib/$i && break
done done
for (( i=1; i < cword; i++ )); do for (( i=1; i < cword; i++ )); do
if [[ "${words[i]}" == --admindir ]]; then if [[ "${words[i]}" == --admindir ]]; then

View File

@ -9,8 +9,8 @@ _update_rc_d()
local sysvdir services options valid_options local sysvdir services options valid_options
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \
|| sysvdir=/etc/init.d || sysvdir=/etc/init.d
services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) ) services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) )
services=( ${services[@]#$sysvdir/} ) services=( ${services[@]#$sysvdir/} )

View File

@ -67,8 +67,8 @@ _cdrecord()
-copy -nocopy -scms isrc= index= padsize= pregap= tsize= ) -copy -nocopy -scms isrc= index= padsize= pregap= tsize= )
# look if previous was either a file or a track option # look if previous was either a file or a track option
track_mode=0 track_mode=0
if [ $cword -gt 1 ]; then if [[ $cword -gt 1 ]]; then
if [ -f "$prev" ]; then if [[ -f $prev ]]; then
track_mode=1 track_mode=1
else else
for (( i=0; i < ${#track_options[@]}; i++ )); do for (( i=0; i < ${#track_options[@]}; i++ )); do
@ -85,7 +85,7 @@ _cdrecord()
# track options are always available # track options are always available
COMPREPLY+=( $( compgen -W '${track_options[@]}' -- "$cur" ) ) COMPREPLY+=( $( compgen -W '${track_options[@]}' -- "$cur" ) )
# general options are no more available after file or track option # general options are no more available after file or track option
if [ $track_mode -eq 0 ]; then if [[ $track_mode -eq 0 ]]; then
COMPREPLY+=( $( compgen -W '${generic_options[@]}' -- "$cur" ) ) COMPREPLY+=( $( compgen -W '${generic_options[@]}' -- "$cur" ) )
fi fi
[[ $COMPREPLY == *= ]] && compopt -o nospace [[ $COMPREPLY == *= ]] && compopt -o nospace

View File

@ -6,19 +6,19 @@ _wtf()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
[ "$prev" = -f ] && _filedir && return 0 [[ $prev == -f ]] && _filedir && return 0
[[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0 [[ $cur == -* ]] && COMPREPLY=( -f ) && return 0
local db local db
set -- "${words[@]}" set -- "${words[@]}"
while [ $# -gt 0 ]; do while [[ $# -gt 0 ]]; do
if [ "$1" = -f ]; then if [[ $1 == -f ]]; then
shift ; db=$1 ; break shift ; db=$1 ; break
fi fi
shift shift
done done
[ -z $db ] && db=${ACRONYMDB:-/usr/share/misc/acronyms*} [[ -z $db ]] && db=${ACRONYMDB:-/usr/share/misc/acronyms*}
COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur^^}" ) ) COMPREPLY=( $( compgen -W "$( cut -f 1 -s $db ) -f" -- "${cur^^}" ) )
} && } &&

View File

@ -29,13 +29,8 @@ doesn't confuse editors as bad as the latter, and is concise enough.
&#91;[ ]] vs [ ] &#91;[ ]] vs [ ]
---------------- ----------------
Use [[ ]] instead of [ ] when testing multiple conditions. [ ] is fine Always use [[ ]] instead of [ ]. Rationale: the former is less error
for single conditions where the syntax works. Rationale: [[ ]] has prone, more featureful, and slightly faster.
short circuit behavior within one test containing multiple conditions
separated by && or ||, while [ ] with -a or -o does not. Thus it can
be more efficient in some cases and may reduce need for nesting
conditions, and it's cleaner to write for example [[ ... && ... ]]
than [ ... ] && [ ... ], and in general [[ ]] has more features.
Line wrapping Line wrapping
------------- -------------