diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-11-09 23:28:11 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-11-09 23:28:11 +0200 |
commit | 3b8ef29ef34d7ea009faca1a35023b454ab2dce1 (patch) | |
tree | 0924cf066806adb3aa7d7b9dcd7f35303292f897 | |
parent | 1d48f79b9c6a9b9e9044741d300ded461d765135 (diff) | |
download | bash-completion-3b8ef29ef34d7ea009faca1a35023b454ab2dce1.tar.gz |
Cleanups: Use [[ instead of [.
76 files changed, 226 insertions, 237 deletions
diff --git a/bash_completion b/bash_completion index cb4f0bfd..1782bc6d 100644 --- a/bash_completion +++ b/bash_completion @@ -265,7 +265,7 @@ __reassemble_comp_words_by_ref() ref="$2[$j]" eval $2[$j]=\${!ref}\${COMP_WORDS[i]} # Indicate new cword - [ $i = $COMP_CWORD ] && eval $3=$j + [[ $i == $COMP_CWORD ]] && eval $3=$j # Remove optional whitespace + word separator from line copy line=${line#*"${COMP_WORDS[$i]}"} # Start new word if word separator in original line is @@ -480,7 +480,7 @@ _get_cword() # _get_pword() { - if [ $COMP_CWORD -ge 1 ]; then + if [[ $COMP_CWORD -ge 1 ]]; then _get_cword "${@:-}" 1 fi } @@ -509,7 +509,7 @@ __ltrim_colon_completions() # Remove colon-word prefix from COMPREPLY items local colon_word=${1%${1##*:}} local i=${#COMPREPLY[*]} - while [ $((--i)) -ge 0 ]; do + while [[ $((--i)) -ge 0 ]]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} done fi @@ -589,7 +589,7 @@ _filedir() -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && \ toks+=( $( compgen -f -- $quoted ) ) - [ ${#toks[@]} -ne 0 ] && compopt -o filenames 2>/dev/null + [[ ${#toks[@]} -ne 0 ]] && compopt -o filenames 2>/dev/null COMPREPLY+=( "${toks[@]}" ) } # _filedir() @@ -824,16 +824,16 @@ _mac_addresses() # _configured_interfaces() { - if [ -f /etc/debian_version ]; then + if [[ -f /etc/debian_version ]]; then # Debian system COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\ /etc/network/interfaces )" -- "$cur" ) ) - elif [ -f /etc/SuSE-release ]; then + elif [[ -f /etc/SuSE-release ]]; then # SuSE system COMPREPLY=( $( compgen -W "$( printf '%s\n' \ /etc/sysconfig/network/ifcfg-* | \ sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) ) - elif [ -f /etc/pld-release ]; then + elif [[ -f /etc/pld-release ]]; then # PLD Linux COMPREPLY=( $( compgen -W "$( command ls -B \ /etc/sysconfig/interfaces | \ @@ -872,9 +872,9 @@ _available_interfaces() { local cmd - if [ "${1:-}" = -w ]; then + if [[ ${1:-} == -w ]]; then cmd="iwconfig" - elif [ "${1:-}" = -a ]; then + elif [[ ${1:-} == -a ]]; then cmd="ifconfig" else cmd="ifconfig -a" @@ -905,7 +905,7 @@ _tilde() # Try generate ~username completions COMPREPLY=( $( compgen -P '~' -u "${1#\~}" ) ) result=${#COMPREPLY[@]} - [ $result -gt 0 ] && compopt -o filenames 2>/dev/null + [[ $result -gt 0 ]] && compopt -o filenames 2>/dev/null fi return $result } @@ -970,7 +970,7 @@ _expand() elif [[ "$cur" == \~* ]]; then cur=${cur#\~} COMPREPLY=( $( compgen -P '~' -u "$cur" ) ) - [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]} + [[ ${#COMPREPLY[@]} -eq 1 ]] && eval COMPREPLY[0]=${COMPREPLY[0]} return ${#COMPREPLY[@]} fi } @@ -1095,7 +1095,7 @@ _service() _init_completion || return # don't complete past 2nd token - [ $cword -gt 2 ] && return 0 + [[ $cword -gt 2 ]] && return 0 if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then _services @@ -1112,7 +1112,7 @@ complete -F _service service _sysvdirs for svcdir in ${sysvdirs[@]}; do for svc in $svcdir/!($_backup_glob); do - [ -x "$svc" ] && complete -F _service $svc + [[ -x $svc ]] && complete -F _service $svc done done unset svc svcdir sysvdirs @@ -1228,7 +1228,7 @@ _fstypes() { local fss - if [ -e /proc/filesystems ] ; then + if [[ -e /proc/filesystems ]]; then # Linux fss="$( cut -d$'\t' -f2 /proc/filesystems ) $( 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 $4 }' /etc/vfstab 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 - [ -n "$fss" ] && \ - COMPREPLY+=( $( compgen -W "$fss" -- "$cur" ) ) + [[ -n $fss ]] && COMPREPLY+=( $( compgen -W "$fss" -- "$cur" ) ) } # Get real command. @@ -1396,26 +1395,25 @@ _known_hosts_real() p) prefix=$OPTARG ;; esac done - [ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD" + [[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD" cur=${!OPTIND}; let "OPTIND += 1" - [ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\ - $(while [ $# -ge $OPTIND ]; do printf '%s\n' ${!OPTIND}; shift; done) + [[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\ + $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done) [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@} kh=() # ssh config files - if [ -n "$configfile" ]; then - [ -r "$configfile" ] && - config+=( "$configfile" ) + if [[ -n $configfile ]]; then + [[ -r $configfile ]] && config+=( "$configfile" ) else for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do - [ -r "$i" ] && config+=( "$i" ) + [[ -r $i ]] && config+=( "$i" ) done fi # Known hosts files from configs - if [ ${#config[@]} -gt 0 ]; then + if [[ ${#config[@]} -gt 0 ]]; then local OIFS=$IFS IFS=$'\n' local -a tmpkh # expand paths (if present) to global and user known hosts files @@ -1428,20 +1426,20 @@ _known_hosts_real() i=${i//\"} # Eval/expand possible `~' or `~user' __expand_tilde_by_ref i - [ -r "$i" ] && kh+=( "$i" ) + [[ -r $i ]] && kh+=( "$i" ) done IFS=$OIFS fi - if [ -z "$configfile" ]; then + if [[ -z $configfile ]]; then # Global and user known_hosts files for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \ ~/.ssh/known_hosts2; do - [ -r "$i" ] && kh+=( "$i" ) + [[ -r $i ]] && kh+=( "$i" ) done for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do - [ -d "$i" ] && khd+=( "$i"/*pub ) + [[ -d $i ]] && khd+=( "$i"/*pub ) done fi @@ -1459,14 +1457,14 @@ _known_hosts_real() # Digits followed by no dot or colon - search for digits followed # by a dot or a colon awkcur="^$awkcur.*[.:]" - elif [ -z "$awkcur" ]; then + elif [[ -z $awkcur ]]; then # A blank - search for a dot, a colon, or an alpha character awkcur="[a-z.:]" else awkcur="^$awkcur" fi - if [ ${#kh[@]} -gt 0 ]; then + if [[ ${#kh[@]} -gt 0 ]]; then # FS needs to look for a comma separated list COMPREPLY+=( $( awk 'BEGIN {FS=","} /^\s*[^|\#]/ { @@ -1477,7 +1475,7 @@ _known_hosts_real() if ($i !~ /[*?]/ && $i ~ /'"$awkcur"'/) {print $i} \ }}' "${kh[@]}" 2>/dev/null ) ) fi - if [ ${#khd[@]} -gt 0 ]; then + if [[ ${#khd[@]} -gt 0 ]]; then # Needs to look for files called # .../.ssh2/key_22_<hostname>.pub # dont fork any processes, because in a cluster environment, @@ -1519,7 +1517,7 @@ _known_hosts_real() # Add results of normal hostname completion, unless # `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+=( $( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ) ) fi @@ -1661,7 +1659,7 @@ _command_offset() fi if [[ -n $cspec ]]; then - if [ "${cspec#* -F }" != "$cspec" ]; then + if [[ ${cspec#* -F } != $cspec ]]; then # complete -F <function> # get function name @@ -1679,7 +1677,7 @@ _command_offset() while true; do # FIXME: should we take "+o opt" into account? t=${cspec#*-o } - if [ "$t" == "$cspec" ]; then + if [[ $t == $cspec ]]; then break fi opt=${t%% *} @@ -1691,7 +1689,7 @@ _command_offset() cspec=${cspec%%$compcmd} COMPREPLY=( $( eval compgen "$cspec" -- "$cur" ) ) fi - elif [ ${#COMPREPLY[@]} -eq 0 ]; then + elif [[ ${#COMPREPLY[@]} -eq 0 ]]; then _minimal fi fi @@ -1800,12 +1798,12 @@ _filedir_xspec() toks+=( $( eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { while read -r tmp; do - [ -n $tmp ] && printf '%s\n' $tmp + [[ -n $tmp ]] && printf '%s\n' $tmp done } )) - [ ${#toks[@]} -ne 0 ] && compopt -o filenames + [[ ${#toks[@]} -ne 0 ]] && compopt -o filenames COMPREPLY=( "${toks[@]}" ) } diff --git a/completions/_mock b/completions/_mock index cb7d6571..020b39b4 100644 --- a/completions/_mock +++ b/completions/_mock @@ -12,7 +12,7 @@ _mock() local cfgdir=/etc/mock count=0 i for i in "${words[@]}" ; do - [ $count -eq $cword ] && break + [[ $count -eq $cword ]] && break if [[ "$i" == --configdir ]] ; then cfgdir="${words[((count+1))]}" elif [[ "$i" == --configdir=* ]] ; then diff --git a/completions/_modules b/completions/_modules index 6f337a90..b5a1d94a 100644 --- a/completions/_modules +++ b/completions/_modules @@ -49,7 +49,7 @@ _module () local cur prev words cword _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 local options @@ -58,7 +58,7 @@ _module () COMPREPLY=( $(compgen -W "$options" -- "$cur") ) - elif [ $cword -eq 2 ] ; then + elif [[ $cword -eq 2 ]]; then case $prev in add|display|help|load|show|whatis) COMPREPLY=( $(_module_avail "$cur") ) @@ -70,7 +70,7 @@ _module () COMPREPLY=( $(_module_path "$cur") ) ;; esac - elif [ $cword -eq 3 ] ; then + elif [[ $cword -eq 3 ]]; then case ${words[1]} in swap|switch) COMPREPLY=( $(_module_avail "$cur") ) diff --git a/completions/_yum b/completions/_yum index c2d37948..9860c540 100644 --- a/completions/_yum +++ b/completions/_yum @@ -45,7 +45,7 @@ _yum() fi done - if [ -n "$special" ]; then + if [[ -n $special ]]; then # TODO: install|update|upgrade should not match *src.rpm if [[ "$cur" == @(*/|[.~])* && \ "$special" == @(deplist|install|update|upgrade) ]]; then diff --git a/completions/ant b/completions/ant index 96ef8172..dd3606dc 100644 --- a/completions/ant +++ b/completions/ant @@ -45,7 +45,7 @@ _ant() break fi done - [ ! -f $buildfile ] && return 0 + [[ ! -f $buildfile ]] && return 0 # parse buildfile for targets local line targets diff --git a/completions/apt-build b/completions/apt-build index aa78b230..8e593131 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -12,7 +12,7 @@ _apt_build() fi done - if [ -n "$special" ]; then + if [[ -n $special ]]; then case $special in install|source|info) COMPREPLY=( $( apt-cache pkgnames "$cur" 2> /dev/null ) ) diff --git a/completions/apt-cache b/completions/apt-cache index 00b41478..3e2ca0db 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -6,7 +6,7 @@ _apt_cache() _init_completion || return local special i - if [ "$cur" != show ]; then + if [[ $cur != show ]]; then for (( i=0; i < ${#words[@]}-1; i++ )); do if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then special=${words[i]} @@ -15,7 +15,7 @@ _apt_cache() fi - if [ -n "$special" ]; then + if [[ -n $special ]]; then case $special in add) _filedir diff --git a/completions/apt-get b/completions/apt-get index 447305a4..a6c902e1 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -12,10 +12,10 @@ _apt_get() fi done - if [ -n "$special" ]; then + if [[ -n $special ]]; then case $special in remove|autoremove|purge) - if [ -f /etc/debian_version ]; then + if [[ -f /etc/debian_version ]]; then # Debian system COMPREPLY=( $( \ _xfunc dpkg _comp_dpkg_installed_packages $cur ) ) diff --git a/completions/avctrl b/completions/avctrl index eb321a07..bac38cd6 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -10,7 +10,7 @@ _avctrl() else local args _count_args - if [ $args -eq 1 ]; then + if [[ $args -eq 1 ]]; then COMPREPLY=( $( compgen -W 'discover switch' -- "$cur" ) ) fi fi diff --git a/completions/cardctl b/completions/cardctl index 0532d6ef..90837269 100644 --- a/completions/cardctl +++ b/completions/cardctl @@ -5,7 +5,7 @@ _cardctl() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'status config ident suspend \ resume reset eject insert scheme' -- "$cur" ) ) fi diff --git a/completions/cfrun b/completions/cfrun index 288bcf43..0be44132 100644 --- a/completions/cfrun +++ b/completions/cfrun @@ -31,7 +31,7 @@ _cfrun() break fi done - [ ! -f $hostfile ] && return 0 + [[ ! -f $hostfile ]] && return 0 COMPREPLY=( $(compgen -W "$( command grep -v \ -E '(=|^$|^#)' $hostfile )" -- "$cur" ) ) diff --git a/completions/cksfv b/completions/cksfv index d21bcf39..eabe3730 100644 --- a/completions/cksfv +++ b/completions/cksfv @@ -5,7 +5,7 @@ _cksfv() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) return 0 fi diff --git a/completions/configure b/completions/configure index 8e28d451..2337c497 100644 --- a/completions/configure +++ b/completions/configure @@ -26,7 +26,7 @@ _configure() # --option=SETTING will include 'SETTING' as a contextual hint [[ "$cur" != -* ]] && return 0 - if [ -n "$COMP_CONFIGURE_HINTS" ]; then + if [[ -n $COMP_CONFIGURE_HINTS ]]; then COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ awk '/^ --[A-Za-z]/ { print $1; \ if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \ diff --git a/completions/cpio b/completions/cpio index ebbe5c57..45824007 100644 --- a/completions/cpio +++ b/completions/cpio @@ -33,7 +33,7 @@ _cpio() $split && return 0 - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \ -? --help --license --usage --version' -- "$cur" ) ) else diff --git a/completions/cryptsetup b/completions/cryptsetup index 2bbdc952..fb390214 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -28,7 +28,7 @@ _cryptsetup() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace diff --git a/completions/cvs b/completions/cvs index bafe1901..4613742a 100644 --- a/completions/cvs +++ b/completions/cvs @@ -13,7 +13,7 @@ _cvs_entries() _cvs_modules() { - if [ -n "$prefix" ]; then + if [[ -n $prefix ]]; then COMPREPLY=( $( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ) ) else COMPREPLY=( $( command ls -d ${cvsroot}/!(CVSROOT) ) ) @@ -39,9 +39,8 @@ _cvs_roots() { local -a cvsroots cvsroots=( $CVSROOT ) - [ -r ~/.cvspass ] && \ - cvsroots+=( $( awk '{ print $2 }' ~/.cvspass ) ) - [ -r CVS/Root ] && mapfile -tO ${#cvsroots[@]} cvsroots < CVS/Root + [[ -r ~/.cvspass ]] && cvsroots+=( $( awk '{ print $2 }' ~/.cvspass ) ) + [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots < CVS/Root COMPREPLY=( $( compgen -W '${cvsroots[@]}' -- "$cur" ) ) __ltrim_colon_completions "$cur" } @@ -56,12 +55,12 @@ _cvs() count=0 for i in "${words[@]}"; do - [ $count -eq $cword ] && break + [[ $count -eq $cword ]] && break # Last parameter was the CVSROOT, now go back to mode selection if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then mode="" fi - if [ -z "$mode" ]; then + if [[ -z $mode ]]; then case $i in -H|--help) COMPREPLY=( $( compgen -W "$( _cvs_commands )" -- "$cur" ) ) @@ -152,7 +151,7 @@ _cvs() if [[ "$cur" != -* ]]; then _cvs_entries - [ -z "$cur" ] && files=( !(CVS) ) || \ + [[ -z $cur ]] && files=( !(CVS) ) || \ files=( $( command ls -d ${cur}* 2>/dev/null ) ) local f for i in ${!files[@]}; do @@ -221,7 +220,7 @@ _cvs() esac if [[ "$cur" != -* ]]; then - [ -z "$cvsroot" ] && cvsroot=$CVSROOT + [[ -z $cvsroot ]] && cvsroot=$CVSROOT COMPREPLY=( $( cvs -d "$cvsroot" co -c 2> /dev/null | \ awk '{print $1}' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) @@ -244,7 +243,7 @@ _cvs() # if $COMP_CVS_REMOTE is not null, 'cvs commit' will # complete on remotely checked-out files (requires # 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 # far, but other changes (something other than # changed/removed/new) may be missing @@ -298,7 +297,7 @@ _cvs() esac if [[ "$cur" != -* ]]; then - [ -z "$cvsroot" ] && cvsroot=$CVSROOT + [[ -z $cvsroot ]] && cvsroot=$CVSROOT COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) else @@ -318,9 +317,9 @@ _cvs() if [[ "$cur" != -* ]]; then # starts with same algorithm as checkout - [ -z "$cvsroot" ] && cvsroot=$CVSROOT + [[ -z $cvsroot ]] && cvsroot=$CVSROOT local prefix=${cur%/*} - if [ -r ${cvsroot}/${prefix} ]; then + if [[ -r ${cvsroot}/${prefix} ]]; then _cvs_modules COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) COMPREPLY=( ${COMPREPLY[@]#\/} ) @@ -337,7 +336,7 @@ _cvs() _cvs_entries # find out what files are missing for i in "${entries[@]}"; do - [ ! -r "$i" ] && miss+=( $i ) + [[ ! -r $i ]] && miss+=( $i ) done COMPREPLY=( $( compgen -W '${miss[@]:-}' -- "$cur" ) ) else diff --git a/completions/dict b/completions/dict index a31816d3..3caedf76 100644 --- a/completions/dict +++ b/completions/dict @@ -17,17 +17,17 @@ _dict() case ${words[i]} in -h|--host) host=${words[i+1]} - [ -n "$host" ] && host="-h $host" + [[ -n $host ]] && host="-h $host" i=$((++i)) ;; -p|--port) port=${words[i+1]} - [ -n "$port" ] && port="-p $port" + [[ -n $port ]] && port="-p $port" i=$((++i)) ;; -d|--database) db=${words[i+1]} - [ -n "$db" ] && host="-d $db" + [[ -n $db ]] && host="-d $db" i=$((++i)) ;; *) @@ -54,7 +54,7 @@ _dict() esac local dictfile=/usr/share/dict/words - [ -r $dictfile ] && \ + [[ -r $dictfile ]] && \ COMPREPLY=( $( compgen -W '$( cat $dictfile )' -- "$cur" ) ) } && complete -F _dict -o default dict rdict diff --git a/completions/e2label b/completions/e2label index 86008d9f..94bcc1c8 100644 --- a/completions/e2label +++ b/completions/e2label @@ -5,7 +5,7 @@ _e2label() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then cur=${cur:=/dev/} _filedir fi diff --git a/completions/feh b/completions/feh index e39b5c31..556fc13e 100644 --- a/completions/feh +++ b/completions/feh @@ -46,7 +46,7 @@ _feh() -T|--theme) local conf_path=~/.config/feh/themes local theme_name theme_opts - [ -r "$conf_path" ] || return + [[ -r $conf_path ]] || return while read theme_name theme_opts; do if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then continue diff --git a/completions/function b/completions/function index 6156e63d..e12fffff 100644 --- a/completions/function +++ b/completions/function @@ -6,12 +6,12 @@ _function() _init_completion || return if [[ $1 == @(declare|typeset) ]]; then - if [ "$prev" = -f ]; then + if [[ $prev == -f ]]; then COMPREPLY=( $( compgen -A function -- "$cur" ) ) elif [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a -f -F -i -r -x -p' -- "$cur" ) ) fi - elif [ $cword -eq 1 ]; then + elif [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -A function -- "$cur" ) ) else COMPREPLY=( "() $( type -- ${words[1]} | sed -e 1,2d )" ) diff --git a/completions/gdb b/completions/gdb index c24407b5..125d0b15 100644 --- a/completions/gdb +++ b/completions/gdb @@ -5,7 +5,7 @@ _gdb() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then local IFS compopt -o filenames if [[ "$cur" == */* ]]; then @@ -24,7 +24,7 @@ _gdb() -mindepth 1 -maxdepth 1 -not -type d -executable \ -printf "%f\\n" 2>/dev/null)' -- "$cur" ) ) fi - elif [ $cword -eq 2 ]; then + elif [[ $cword -eq 2 ]]; then COMPREPLY=( $( compgen -W "$( command ps axo comm,pid | \ awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}' )" -- "$cur" ) ) compopt -o filenames diff --git a/completions/gpg b/completions/gpg index 763086bc..f7efad3a 100644 --- a/completions/gpg +++ b/completions/gpg @@ -20,7 +20,7 @@ _gpg() -r|--recipient) COMPREPLY=( $( compgen -W "$( gpg --list-keys 2>/dev/null | \ sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )) - if [ -e ~/.gnupg/gpg.conf ]; then + if [[ -e ~/.gnupg/gpg.conf ]]; then COMPREPLY+=( $( compgen -W "$( sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ ~/.gnupg/gpg.conf )" -- "$cur") ) diff --git a/completions/gpg2 b/completions/gpg2 index 03d2c5b8..85e9f38c 100644 --- a/completions/gpg2 +++ b/completions/gpg2 @@ -24,7 +24,7 @@ _gpg2() -r|--recipient) COMPREPLY=( $( compgen -W "$( gpg2 --list-keys 2>/dev/null | \ sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur" )) - if [ -e ~/.gnupg/gpg.conf ]; then + if [[ -e ~/.gnupg/gpg.conf ]]; then COMPREPLY+=( $( compgen -W "$( sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ ~/.gnupg/gpg.conf)" -- "$cur")) diff --git a/completions/hcitool b/completions/hcitool index 417a0c99..0a743e48 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -2,7 +2,7 @@ _bluetooth_adresses() { - if [ -n "${COMP_BLUETOOTH_SCAN:-}" ]; then + if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then COMPREPLY+=( $( compgen -W "$( hcitool scan | \ awk '/^\t/{print $1}' )" -- "$cur" ) ) fi @@ -51,7 +51,7 @@ _hcitool() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else @@ -63,7 +63,7 @@ _hcitool() case $arg in name|info|dc|rssi|lq|afh|auth|key|clkoff|lst) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses fi ;; @@ -72,14 +72,14 @@ _hcitool() COMPREPLY=( $( compgen -W '--role --pkt-type' -- "$cur" ) ) else _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses fi fi ;; sr) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses else COMPREPLY=( $( compgen -W 'master slave' -- "$cur" ) ) @@ -87,7 +87,7 @@ _hcitool() ;; cpt) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses else _bluetooth_packet_types @@ -95,7 +95,7 @@ _hcitool() ;; tpl|enc|clock) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses else COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) ) @@ -122,7 +122,7 @@ _sdptool() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else @@ -206,7 +206,7 @@ _rfcomm() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else @@ -215,12 +215,12 @@ _rfcomm() fi else _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_devices else case $arg in connect|bind) - if [ $args -eq 3 ]; then + if [[ $args -eq 3 ]]; then _bluetooth_adresses fi ;; @@ -245,7 +245,7 @@ _ciptool() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) else @@ -256,7 +256,7 @@ _ciptool() case $arg in connect|release|loopback) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses fi ;; @@ -302,7 +302,7 @@ _hciconfig() local arg _get_first_arg - if [ -z $arg ]; then + if [[ -z $arg ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --all' -- "$cur" ) ) else @@ -318,20 +318,20 @@ _hciconfig() case $arg in putkey|delkey) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_adresses fi ;; lm) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then COMPREPLY=( $( compgen -W 'MASTER \ SLAVE NONE ACCEPT' -- "$cur" ) ) fi ;; ptype) _count_args - if [ $args -eq 2 ]; then + if [[ $args -eq 2 ]]; then _bluetooth_packet_types fi ;; diff --git a/completions/ifup b/completions/ifup index fee87d6b..fcd34994 100644 --- a/completions/ifup +++ b/completions/ifup @@ -7,7 +7,7 @@ _ifupdown() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then _configured_interfaces COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) fi diff --git a/completions/info b/completions/info index 71865809..36550449 100644 --- a/completions/info +++ b/completions/info @@ -45,12 +45,12 @@ _info() if [[ $INFOPATH == *: ]]; then infopath=${INFOPATH}${infopath} - elif [ ${INFOPATH:+set} ]; then + elif [[ ${INFOPATH:+set} ]]; then infopath=$INFOPATH fi infopath=$infopath: - if [ -n "$cur" ]; then + if [[ -n $cur ]]; then infopath="${infopath//://$cur* }" else infopath="${infopath//:// }" @@ -62,9 +62,7 @@ _info() COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) # weed out info dir file for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do - if [ "${COMPREPLY[$i]}" == 'dir' ]; then - unset COMPREPLY[$i] - fi + [[ ${COMPREPLY[$i]} == dir ]] && unset COMPREPLY[$i] done # strip suffix from info pages COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} ) diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d index fd2c1db0..d4e0d245 100644 --- a/completions/invoke-rc.d +++ b/completions/invoke-rc.d @@ -9,8 +9,8 @@ _invoke_rc_d() local sysvdir services options valid_options - [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ - || sysvdir=/etc/init.d + [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d services=( $( printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob) ) ) services=( ${services[@]#$sysvdir/} ) @@ -24,7 +24,7 @@ _invoke_rc_d() | sort | uniq -u \ ) ) COMPREPLY=( $( compgen -W '${valid_options[@]} ${services[@]}' -- "$cur" ) ) - elif [ -x $sysvdir/$prev ]; then + elif [[ -x $sysvdir/$prev ]]; then COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ $sysvdir/$prev`' -- "$cur" ) ) diff --git a/completions/ipmitool b/completions/ipmitool index 81a6466f..281d9eac 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -71,11 +71,11 @@ _ipmitool() for (( i=1; i < ${#words[@]}-1; i++ )); do [[ -n $cmd ]] && subcmd=${words[i]} && break for c in ${cmds[@]}; do - [ ${words[i]} = $c ] && cmd=$c && break + [[ ${words[i]} == $c ]] && cmd=$c && break done done - if [ -z "$cmd" ]; then + if [[ -z $cmd ]]; then COMPREPLY=( $( compgen -W '${cmds[@]}' -- "$cur" ) ) return 0 fi @@ -100,11 +100,11 @@ _ipmitool() print|set) ;; alert) - [ "$prev" = alert ] && \ + [[ $prev == alert ]] && \ COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) ;; stats) - [ "$prev" = stats ] && \ + [[ $prev == stats ]] && \ COMPREPLY=( $( compgen -W 'print set' -- "$cur" ) ) ;; *) @@ -161,7 +161,7 @@ _ipmitool() _filedir ;; time) - [ "$prev" = time ] && \ + [[ $prev == time ]] && \ COMPREPLY=( $( compgen -W 'get set' -- "$cur" ) ) ;; *) @@ -176,7 +176,7 @@ _ipmitool() summary|list|disable|enable|priv|test) ;; set) - [ "$prev" = set ] && \ + [[ $prev == set ]] && \ COMPREPLY=( $( compgen -W 'name password' -- "$cur" ) ) ;; *) @@ -187,7 +187,7 @@ _ipmitool() ;; set) - [ "$prev" = set ] && \ + [[ $prev == set ]] && \ COMPREPLY=( $( compgen -W 'hostname username password privlvl authtype localaddr targetaddr port csv verbose' \ -- "$cur" ) ) diff --git a/completions/ipsec b/completions/ipsec index 1a081028..a586a786 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -18,7 +18,7 @@ _ipsec_freeswan() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'auto barf eroute klipsdebug look manual \ pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp \ tncfg whack' -- "$cur" ) ) @@ -55,7 +55,7 @@ _ipsec_strongswan() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'down irdumm leases listaacerts listacerts \ listalgs listall listcacerts listcainfos listcards listcerts \ listcrls listgroups listocsp listocspcerts listpubkeys openac pki diff --git a/completions/iptables b/completions/iptables index b9314f23..5c4e0736 100644 --- a/completions/iptables +++ b/completions/iptables @@ -29,12 +29,12 @@ _iptables() `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ "$cur" ) ) - elif [ "$table" = "-t nat" ]; then + elif [[ $table == "-t nat" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \ sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \ -- "$cur" ) ) - elif [ "$table" = "-t mangle" ]; then + elif [[ $table == "-t mangle" ]]; then COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \ MARK TOS `iptables $table -nL | sed -ne "$chain" \ -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \ diff --git a/completions/isql b/completions/isql index 695654f3..43cd6dd3 100644 --- a/completions/isql +++ b/completions/isql @@ -6,7 +6,7 @@ _isql() local cur prev words cword _init_completion || return - [ -f "$ODBCINI" ] \ + [[ -f $ODBCINI ]] \ && COMPREPLY=( $( command grep \\["$cur" "$ODBCINI" | tr -d \\[\\] ) ) } && complete -F _isql isql diff --git a/completions/iwconfig b/completions/iwconfig index 81dda723..899f1493 100644 --- a/completions/iwconfig +++ b/completions/iwconfig @@ -13,7 +13,7 @@ _iwconfig() ;; essid) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) - if [ -n "${COMP_IWLIST_SCAN:-}" ]; then + if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then COMPREPLY+=( $( compgen -W \ "$( iwlist ${words[1]} scan | \ awk -F'\"' '/ESSID/ {print $2}' )" -- "$cur" ) ) @@ -37,7 +37,7 @@ _iwconfig() ;; ap) COMPREPLY=( $( compgen -W 'on off any' -- "$cur" ) ) - if [ -n "${COMP_IWLIST_SCAN:-}" ]; then + if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then COMPREPLY+=( $( compgen -W \ "$( iwlist ${words[1]} scan | \ awk -F ': ' '/Address/ {print $2}' )" -- "$cur" ) ) @@ -73,7 +73,7 @@ _iwconfig() ;; esac - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) else diff --git a/completions/iwlist b/completions/iwlist index 39bfa0f1..7819b04d 100644 --- a/completions/iwlist +++ b/completions/iwlist @@ -5,7 +5,7 @@ _iwlist() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) else diff --git a/completions/iwpriv b/completions/iwpriv index b0d45043..05952c5e 100644 --- a/completions/iwpriv +++ b/completions/iwpriv @@ -16,7 +16,7 @@ _iwpriv() ;; esac - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) else diff --git a/completions/iwspy b/completions/iwspy index 4bffc76e..b59b0693 100644 --- a/completions/iwspy +++ b/completions/iwspy @@ -5,7 +5,7 @@ _iwspy() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) ) else diff --git a/completions/java b/completions/java index e02f7369..c302d1e5 100644 --- a/completions/java +++ b/completions/java @@ -21,10 +21,10 @@ _java_find_classpath() done # default to environment - [ -z "$classpath" ] && classpath=$CLASSPATH + [[ -z $classpath ]] && classpath=$CLASSPATH # default to current directory - [ -z "$classpath" ] && classpath=. + [[ -z $classpath ]] && classpath=. } # exact sourcepath determination @@ -41,7 +41,7 @@ _java_find_sourcepath() done # default to classpath - if [ -z "$sourcepath" ]; then + if [[ -z $sourcepath ]]; then local classpath _java_find_classpath sourcepath=$classpath @@ -69,7 +69,7 @@ _java_classes() command grep '^[^$]*\.class$' ) ) fi - elif [ -d $i ]; then + elif [[ -d $i ]]; then COMPREPLY+=( $( compgen -d -- "$i/$cur" | sed -e "s|^$i/\(.*\)|\1.|" ) $( compgen -f -X '!*.class' -- "$i/$cur" | \ @@ -101,7 +101,7 @@ _java_packages() cur=${cur//.//} # parse each sourcepath element for packages for i in ${sourcepath//:/ }; do - if [ -d $i ]; then + if [[ -d $i ]]; then COMPREPLY+=( $( command ls -F -d $i/$cur* 2>/dev/null | \ sed -e 's|^'$i'/||' ) ) fi diff --git a/completions/kldload b/completions/kldload index 26ab0e19..f362db69 100644 --- a/completions/kldload +++ b/completions/kldload @@ -8,7 +8,7 @@ _kldload() _init_completion || return local moddir=/modules/ - [ -d $moddir ] || moddir=/boot/kernel/ + [[ -d $moddir ]] || moddir=/boot/kernel/ compopt -o filenames COMPREPLY=( $( compgen -f "$moddir$cur" ) ) diff --git a/completions/links b/completions/links index a212fa5a..5adc7de3 100644 --- a/completions/links +++ b/completions/links @@ -18,7 +18,7 @@ _links() -source -version -help' -- "$cur" ) ) ;; *) - if [ -r ~/.links/links.his ]; then + if [[ -r ~/.links/links.his ]]; then COMPREPLY=( $( compgen -W '$( < ~/.links/links.his )' \ -- "$cur" ) ) fi diff --git a/completions/lvm b/completions/lvm index 7b353114..b657e0bd 100644 --- a/completions/lvm +++ b/completions/lvm @@ -314,7 +314,7 @@ _vgcreate() --verbose --version' -- "$cur" ) ) else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _volumegroups else _physicalvolumes @@ -373,7 +373,7 @@ _vgreduce() else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _volumegroups else _physicalvolumes @@ -402,7 +402,7 @@ _vgextend() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _volumegroups else _physicalvolumes @@ -686,7 +686,7 @@ _lvcreate() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _volumegroups else _physicalvolumes @@ -779,7 +779,7 @@ _lvresize() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _logicalvolumes else _physicalvolumes @@ -808,7 +808,7 @@ _lvextend() COMPREPLY=( $( compgen -W '$( _parse_usage "$1" --help )' -- "$cur" ) ) else _args - if [ $args -eq 0 ]; then + if [[ $args -eq 0 ]]; then _logicalvolumes else _physicalvolumes @@ -822,7 +822,7 @@ _lvm() local cur prev words cword _init_completion || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \ lvcreate lvdisplay lvextend lvmchange \ lvmdiskscan lvmsadc lvmsar lvreduce \ diff --git a/completions/make b/completions/make index 2c9a2c5a..32fad165 100644 --- a/completions/make +++ b/completions/make @@ -58,8 +58,8 @@ _make() fi done - [ -n "$makef" ] && makef="-f ${makef}" - [ -n "$makef_dir" ] && makef_dir="-C ${makef_dir}" + [[ -n $makef ]] && makef="-f ${makef}" + [[ -n $makef_dir ]] && makef_dir="-C ${makef_dir}" COMPREPLY=( $( compgen -W "$( make -qp $makef $makef_dir 2>/dev/null | \ awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \ diff --git a/completions/man b/completions/man index 5c134d33..a9de57c4 100644 --- a/completions/man +++ b/completions/man @@ -63,7 +63,7 @@ _man() manpath=$MANPATH fi - if [ -z "$manpath" ]; then + if [[ -z $manpath ]]; then COMPREPLY=( $( compgen -c -- "$cur" ) ) return 0 fi @@ -72,7 +72,7 @@ _man() [[ "$prev" == $mansect ]] && sect=$prev || sect='*' manpath=$manpath: - if [ -n "$cur" ]; then + if [[ -n $cur ]]; then manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }" else manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }" diff --git a/completions/minicom b/completions/minicom index 6bac50ba..cad90926 100644 --- a/completions/minicom +++ b/completions/minicom @@ -29,11 +29,10 @@ _minicom() return 0 else local confdir - [ -n "$( command ls /etc/minirc.* 2>/dev/null)" ] \ - && confdir=/etc - [ -n "$( command ls /etc/minicom/minirc.* 2>/dev/null)" ] \ + [[ -n $( command ls /etc/minirc.* 2>/dev/null ) ]] && confdir=/etc + [[ -n $( command ls /etc/minicom/minirc.* 2>/dev/null ) ]] \ && confdir=/etc/minicom - if [ -n "$confdir" ]; then + if [[ -n $confdir ]]; then COMPREPLY=( $( compgen -W '$( printf "%s\n" $confdir/minirc.* | \ sed -e "s|$confdir/minirc.||")' -- "$cur" ) ) return 0 diff --git a/completions/mount b/completions/mount index 48bc7b03..e1acef1e 100644 --- a/completions/mount +++ b/completions/mount @@ -92,7 +92,7 @@ _mount() if [[ "$cur" == *:* ]]; then for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do - [ -x "$sm" ] || continue + [[ -x $sm ]] || continue COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \ awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) ) return 0 @@ -102,24 +102,24 @@ _mount() if [[ "$cur" == //* ]]; then host=${cur#//} host=${host%%/*} - if [ -n "$host" ]; then + if [[ -n $host ]]; then COMPREPLY=( $( compgen -P "//$host" -W \ "$( smbclient -d 0 -NL $host 2>/dev/null | sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' | sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \ -- "${cur#//$host}" ) ) fi - elif [ -r /etc/vfstab ]; then + elif [[ -r /etc/vfstab ]]; then # Solaris COMPREPLY=( $( compgen -W "$( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab )" -- "$cur" ) ) - elif [ ! -e /etc/fstab ]; then + elif [[ ! -e /etc/fstab ]]; then # probably Cygwin COMPREPLY=( $( compgen -W "$( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' )" -- "$cur" ) ) else # probably Linux - if [ "$prev" = -L ]; then + if [[ $prev == -L ]]; then _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" ) ) else _linux_fstab < /etc/fstab diff --git a/completions/mplayer b/completions/mplayer index cd39d309..be852a5a 100644 --- a/completions/mplayer +++ b/completions/mplayer @@ -30,7 +30,7 @@ _mplayer() return 0 ;; -font|-subfont) - if [ "$prev" = -font ]; then + if [[ $prev == -font ]]; then _filedir '@(desc|ttf)' else _filedir ttf @@ -67,7 +67,7 @@ _mplayer() # if you don't have installed mplayer in /usr you # may want to set the MPLAYER_SKINS_DIR global variable local -a dirs - if [ -n "$MPLAYER_SKINS_DIR" ]; then + if [[ -n $MPLAYER_SKINS_DIR ]]; then dirs=($MPLAYER_SKINS_DIR) else dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins) diff --git a/completions/mtx b/completions/mtx index 0dae92ae..0cb63251 100644 --- a/completions/mtx +++ b/completions/mtx @@ -20,7 +20,7 @@ _mtx() drives=${drives//:Full} drives=${drives//:Empty} - if [ $cword -gt 1 ]; then + if [[ $cword -gt 1 ]]; then case $prev in load) COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) ) diff --git a/completions/mutt b/completions/mutt index f1fd6ff7..e840a4a9 100644 --- a/completions/mutt +++ b/completions/mutt @@ -21,23 +21,23 @@ _muttrc() { # Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument set -- "${words[@]}" - while [ $# -gt 0 ]; do + while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then - if [ ${#1} -gt 2 ]; then + if [[ ${#1} -gt 2 ]]; then muttrc="$(dequote "${1:2}")" else shift - [ "$1" ] && muttrc="$(dequote "$1")" + [[ $1 ]] && muttrc="$(dequote "$1")" fi break fi shift done - if [ -z "$muttrc" ]; then - if [ -f ~/.${muttcmd}rc ]; then + if [[ -z $muttrc ]]; then + if [[ -f ~/.${muttcmd}rc ]]; then muttrc="~/.${muttcmd}rc" - elif [ -f ~/.${muttcmd}/${muttcmd}rc ]; then + elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then muttrc="~/.${muttcmd}/${muttcmd}rc" fi fi @@ -77,7 +77,7 @@ _muttaliases() local -a conffiles aliases muttrc=$(_muttrc) - [ -z "$muttrc" ] && return 0 + [[ -z $muttrc ]] && return 0 conffiles=( $(eval _muttconffiles $muttrc $muttrc) ) aliases=( $( sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \ @@ -125,10 +125,10 @@ _muttfiledir() COMPREPLY=( $( compgen -f -- "$folder/${cur:1}" ) ) COMPREPLY=( ${COMPREPLY[@]#$folder/} ) return 0 - elif [ "$cur" == !* ]; then + elif [[ $cur == !* ]]; then spoolfile="$( $muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \ sed -e 's|^spoolfile=\"\(.*\)\"$|\1|' )" - [ ! -z "$spoolfile" ] && eval cur="${cur/^!/$spoolfile}" + [[ ! -z $spoolfile ]] && eval cur="${cur/^!/$spoolfile}" fi _filedir diff --git a/completions/mysql b/completions/mysql index effd313c..c41c1667 100644 --- a/completions/mysql +++ b/completions/mysql @@ -20,7 +20,7 @@ _mysql() return 0 ;; --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" ) ) return 0 ;; diff --git a/completions/openssl b/completions/openssl index 68a13c2a..b63d215d 100644 --- a/completions/openssl +++ b/completions/openssl @@ -13,14 +13,14 @@ _openssl_sections() done # 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 \ /usr/share/ssl/openssl.cnf; do - [ -f $f ] && config=$f && break + [[ -f $f ]] && config=$f && break done fi - [ ! -f "$config" ] && return 0 + [[ ! -f $config ]] && return 0 COMPREPLY=( $( compgen -W "$( awk '/\[.*\]/ {print $2}' $config )" \ -- "$cur" ) ) @@ -48,7 +48,7 @@ _openssl() rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 \ rc4-40' - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) ) else command=${words[1]} diff --git a/completions/p4 b/completions/p4 index 59d1bcd9..d0d984b2 100644 --- a/completions/p4 +++ b/completions/p4 @@ -14,9 +14,9 @@ _p4() uresource uxbinary xbinary xltext xtempobj xtext \ text binary resource" - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W "$p4commands" -- "$cur" ) ) - elif [ $cword -eq 2 ]; then + elif [[ $cword -eq 2 ]]; then case $prev in help) COMPREPLY=( $( compgen -W "simple commands \ @@ -29,7 +29,7 @@ _p4() *) ;; esac - elif [ $cword -gt 2 ]; then + elif [[ $cword -gt 2 ]]; then case $prev in -t) case ${words[$cword-2]} in diff --git a/completions/povray b/completions/povray index e5ef9df6..fa2f9812 100644 --- a/completions/povray +++ b/completions/povray @@ -40,7 +40,7 @@ _povray() *.ini\[|*.ini\[*[^]]) # sections in .ini files cur="${povcur#*\[}" pfx="${povcur%\["$cur"}" # prefix == filename - [ -r "$pfx" ] || return 0 + [[ -r $pfx ]] || return 0 COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \ -e 't' -e 'd' -- "$pfx") ) # to prevent [bar] expand to nothing. can be done more easily? diff --git a/completions/psql b/completions/psql index 7e4276bc..186177a3 100644 --- a/completions/psql +++ b/completions/psql @@ -13,7 +13,7 @@ _pg_users() # -w was introduced in 8.4, https://launchpad.net/bugs/164772 COMPREPLY=( $( compgen -W "$( psql -Atqwc 'select usename from pg_user' \ template1 2>/dev/null )" -- "$cur" ) ) - [ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- "$cur" ) ) + [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) ) } # createdb(1) completion diff --git a/completions/puppet b/completions/puppet index 776c8492..66a81b3b 100644 --- a/completions/puppet +++ b/completions/puppet @@ -2,7 +2,7 @@ _puppet_logdest() { - if [ -z "$cur" ]; then + if [[ -z $cur ]]; then COMPREPLY=( $( compgen -W 'syslog console /' -- "$cur" ) ) else COMPREPLY=( $( compgen -W 'syslog console' -- "$cur" ) ) diff --git a/completions/qdbus b/completions/qdbus index 5ed6bf89..a098fbc9 100644 --- a/completions/qdbus +++ b/completions/qdbus @@ -5,7 +5,7 @@ _qdbus() local cur prev words cword _init_completion || return - [ -n "$cur" ] && unset words[${#words[@]}-1] + [[ -n $cur ]] && unset words[${#words[@]}-1] COMPREPLY=( $( compgen -W '$( command ${words[@]} 2>/dev/null | \ sed s/\(.*\)// )' -- "$cur" ) ) } && diff --git a/completions/rcs b/completions/rcs index a8eac85b..67c1c9d8 100644 --- a/completions/rcs +++ b/completions/rcs @@ -11,7 +11,7 @@ _rcs() dir=${cur%/*} # deal with relative directory - [ "$file" = "$dir" ] && dir=. + [[ $file == $dir ]] && dir=. COMPREPLY=( $( compgen -f "$dir/RCS/$file" ) ) diff --git a/completions/ri b/completions/ri index 70756325..43f6408a 100644 --- a/completions/ri +++ b/completions/ri @@ -5,10 +5,10 @@ ri_get_methods() { local regex - if [ "$ri_version" = integrated ]; then - if [ -z "$separator" ]; then + if [[ $ri_version == integrated ]]; then + if [[ -z $separator ]]; then regex="(Instance|Class)" - elif [ "$separator" = "#" ]; then + elif [[ $separator == "#" ]]; then regex=Instance else regex=Class @@ -45,7 +45,7 @@ _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 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 IFS=$', \n\t' @@ -60,11 +60,11 @@ _ri() return 0 fi - if [ "$ri_version" = integrated ]; then + if [[ $ri_version == integrated ]]; then # integrated ri from Ruby 1.9 classes=( $( ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \ if /, [A-Z]+/ then print; end; end' 2>/dev/null ) ) - elif [ "$ri_version" = "ri 1.8a" ]; then + elif [[ $ri_version == "ri 1.8a" ]]; then classes=( $( ruby -W0 $ri_path | \ ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \ if /^ .*[A-Z]/ then print; end; end' )) diff --git a/completions/route b/completions/route index 14fc2599..40d4f490 100644 --- a/completions/route +++ b/completions/route @@ -7,7 +7,7 @@ _route() local cur prev words cword _init_completion || return - if [ "$prev" = dev ]; then + if [[ $prev == dev ]]; then _available_interfaces return 0 fi @@ -18,7 +18,7 @@ _route() dyn reinstate dev default gw; do found=false for (( i=1; i < ${#words[@]}-1; i++ )); do - [ "${words[i]}" = "$opt" ] && found=true && break + [[ ${words[i]} == $opt ]] && found=true && break done $found || COMPREPLY[${#COMPREPLY[@]}]="$opt" done diff --git a/completions/rpcdebug b/completions/rpcdebug index 6d4acf52..3501af13 100644 --- a/completions/rpcdebug +++ b/completions/rpcdebug @@ -11,7 +11,7 @@ _rpcdebug_flags() fi done - if [ -n "$module" ]; then + if [[ -n $module ]]; then COMPREPLY=( $( compgen -W "$( rpcdebug -vh 2>&1 | \ sed -ne 's/^'$module'[[:space:]]\{1,\}//p' )" -- "$cur" ) ) fi diff --git a/completions/rpm b/completions/rpm index c7e67705..c73c59e9 100644 --- a/completions/rpm +++ b/completions/rpm @@ -48,7 +48,7 @@ _rpm() local cur prev words cword split _init_completion -s || return - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then # first parameter on line case $cur in --*) diff --git a/completions/rrdtool b/completions/rrdtool index 9280d8f5..8170c9fe 100644 --- a/completions/rrdtool +++ b/completions/rrdtool @@ -5,7 +5,7 @@ _rrdtool () local cur prev words cword _init_completion || return - if [ ${#words[@]} -eq 2 ]; then + if [[ ${#words[@]} -eq 2 ]]; then COMPREPLY=( $( compgen -W 'create update updatev graph dump restore \ last lastupdate first info fetch tune resize xport' -- "$cur" ) ) else diff --git a/completions/rsync b/completions/rsync index e8b75b1a..e3f0f10e 100644 --- a/completions/rsync +++ b/completions/rsync @@ -74,7 +74,7 @@ _rsync() break fi done - [ "$shell" = ssh ] && _xfunc ssh _scp_remote_files + [[ $shell == ssh ]] && _xfunc ssh _scp_remote_files ;; *) _known_hosts_real -c -a "$cur" diff --git a/completions/sbopkg b/completions/sbopkg index 647355b0..d0bf9a2b 100644 --- a/completions/sbopkg +++ b/completions/sbopkg @@ -45,7 +45,7 @@ _sbopkg() fi done - if [ ! -r "$config" ]; then + if [[ ! -r $config ]]; then return 0 fi @@ -63,7 +63,7 @@ _sbopkg() esac 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 fi COMPREPLY=( $( sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\ diff --git a/completions/sitecopy b/completions/sitecopy index 1f18514a..12480e97 100644 --- a/completions/sitecopy +++ b/completions/sitecopy @@ -40,7 +40,7 @@ _sitecopy() ;; esac - if [ -r ~/.sitecopyrc ]; then + if [[ -r ~/.sitecopyrc ]]; then COMPREPLY=( $( compgen -W "$($1 -v | \ command sed -n '/^Site:/s/Site: //p')" -- "$cur" ) ) fi diff --git a/completions/slackpkg b/completions/slackpkg index 1d5759cb..9648d25a 100644 --- a/completions/slackpkg +++ b/completions/slackpkg @@ -43,7 +43,7 @@ _slackpkg() local confdir="/etc/slackpkg" local config="$confdir/slackpkg.conf" - if [ ! -r "$config" ]; then + if [[ ! -r $config ]]; then return 0 fi . "$config" @@ -62,7 +62,7 @@ _slackpkg() return 0 ;; install-template|remove-template) - if [ -e "$confdir/templates" ]; then + if [[ -e $confdir/templates ]]; then COMPREPLY=( $( cd "$confdir/templates"; \ compgen -f -X "!*.template" -- "$cur" ) ) COMPREPLY=( ${COMPREPLY[@]%.template} ) diff --git a/completions/slapt-get b/completions/slapt-get index 99b50384..d18695cd 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -48,7 +48,7 @@ _slapt_get() break fi done - if [ ! -r "$config" ]; then + if [[ ! -r $config ]]; then return fi diff --git a/completions/slapt-src b/completions/slapt-src index 976ef65e..64b196e7 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -30,7 +30,7 @@ _slapt_src() break fi done - if [ "$t" != "all" ]; then + if [[ $t != all ]]; then return 0 fi @@ -42,7 +42,7 @@ _slapt_src() break fi done - if [ ! -r "$config" ]; then + if [[ ! -r $config ]]; then return 0 fi diff --git a/completions/smbclient b/completions/smbclient index ceda7bbf..b7371907 100644 --- a/completions/smbclient +++ b/completions/smbclient @@ -7,14 +7,14 @@ _samba_resolve_order() _samba_domains() { - if [ -n "${COMP_SAMBA_SCAN:-}" ]; then + if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then COMPREPLY=( $( compgen -W '$( smbtree -N -D )' -- "$cur" ) ) fi } _samba_hosts() { - if [ -n "${COMP_SAMBA_SCAN:-}" ]; then + if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then COMPREPLY=( $( compgen -W "$( smbtree -N -S | \ sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \ )" -- $cur ) ) diff --git a/completions/ssh b/completions/ssh index e62b13fd..a18ba494 100644 --- a/completions/ssh +++ b/completions/ssh @@ -157,20 +157,20 @@ _ssh() else # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument set -- "${words[@]}" - while [ $# -gt 0 ]; do + while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then - if [ ${#1} -gt 2 ]; then + if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift - [ "$1" ] && configfile="$(dequote "$1")" + [[ $1 ]] && configfile="$(dequote "$1")" fi break fi shift done _known_hosts_real -a -F "$configfile" "$cur" - if [ $cword -ne 1 ]; then + if [[ $cword -ne 1 ]]; then compopt -o filenames COMPREPLY+=( $( compgen -c -- "$cur" ) ) fi @@ -220,13 +220,13 @@ _sftp() else # Search COMP_WORDS for '-F configfile' argument set -- "${words[@]}" - while [ $# -gt 0 ]; do + while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then - if [ ${#1} -gt 2 ]; then + if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift - [ "$1" ] && configfile="$(dequote "$1")" + [[ $1 ]] && configfile="$(dequote "$1")" fi break fi @@ -258,12 +258,12 @@ _scp_remote_files() path=$( sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" ) # 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) fi local files - if [ "$1" = -d ] ; then + if [[ $1 == -d ]]; then # escape problematic characters; remove non-dirs files=$( ssh -o 'Batchmode yes' $userhost \ command ls -aF1d "$path*" 2>/dev/null | \ @@ -288,7 +288,7 @@ _scp_local_files() local IFS=$'\n' local dirsonly=false - if [ "$1" = -d ]; then + if [[ $1 == -d ]]; then dirsonly=true shift fi @@ -350,13 +350,13 @@ _scp() else # Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument set -- "${words[@]}" - while [ $# -gt 0 ]; do + while [[ $# -gt 0 ]]; do if [[ $1 == -F* ]]; then - if [ ${#1} -gt 2 ]; then + if [[ ${#1} -gt 2 ]]; then configfile="$(dequote "${1:2}")" else shift - [ "$1" ] && configfile="$(dequote "$1")" + [[ $1 ]] && configfile="$(dequote "$1")" fi break fi diff --git a/completions/strace b/completions/strace index 0ac4163a..9d28a54e 100644 --- a/completions/strace +++ b/completions/strace @@ -21,7 +21,7 @@ _strace() break done - if [ $offset -gt 0 ]; then + if [[ $offset -gt 0 ]]; then _command_offset $offset else diff --git a/completions/tar b/completions/tar index 9d1c56a4..45f3ff36 100644 --- a/completions/tar +++ b/completions/tar @@ -7,7 +7,7 @@ _tar() 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" ) ) return 0 fi diff --git a/completions/unace b/completions/unace index 4ce5e370..369417ce 100644 --- a/completions/unace +++ b/completions/unace @@ -5,10 +5,10 @@ _unace() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]] ; then + if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur" ) ) else - if [ $cword -eq 1 ]; then + if [[ $cword -eq 1 ]]; then COMPREPLY=( $( compgen -W 'e l t v x' -- "$cur" ) ) else _filedir ace diff --git a/completions/unrar b/completions/unrar index d99e62fe..67a316ff 100644 --- a/completions/unrar +++ b/completions/unrar @@ -5,12 +5,12 @@ _unrar() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]] ; then + if [[ $cur == -* ]]; then COMPREPLY=( $( compgen -W '-ad -ap -av- -c- -cfg- -cl -cu \ -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" ) ) 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" ) ) else _filedir rar diff --git a/completions/update-alternatives b/completions/update-alternatives index 523e1de5..051b1142 100644 --- a/completions/update-alternatives +++ b/completions/update-alternatives @@ -5,7 +5,7 @@ _installed_alternatives() local admindir # find the admin dir 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 for (( i=1; i < cword; i++ )); do if [[ "${words[i]}" == --admindir ]]; then diff --git a/completions/update-rc.d b/completions/update-rc.d index b1d21e86..3dbad2e5 100644 --- a/completions/update-rc.d +++ b/completions/update-rc.d @@ -9,8 +9,8 @@ _update_rc_d() local sysvdir services options valid_options - [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d \ - || sysvdir=/etc/init.d + [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ + || sysvdir=/etc/init.d services=( $(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)) ) services=( ${services[@]#$sysvdir/} ) diff --git a/completions/wodim b/completions/wodim index 3bc304d1..b6ce2aa6 100644 --- a/completions/wodim +++ b/completions/wodim @@ -67,8 +67,8 @@ _cdrecord() -copy -nocopy -scms isrc= index= padsize= pregap= tsize= ) # look if previous was either a file or a track option track_mode=0 - if [ $cword -gt 1 ]; then - if [ -f "$prev" ]; then + if [[ $cword -gt 1 ]]; then + if [[ -f $prev ]]; then track_mode=1 else for (( i=0; i < ${#track_options[@]}; i++ )); do @@ -85,7 +85,7 @@ _cdrecord() # track options are always available COMPREPLY+=( $( compgen -W '${track_options[@]}' -- "$cur" ) ) # 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" ) ) fi [[ $COMPREPLY == *= ]] && compopt -o nospace diff --git a/completions/wtf b/completions/wtf index b176d09b..cc8352f4 100644 --- a/completions/wtf +++ b/completions/wtf @@ -6,19 +6,19 @@ _wtf() local cur prev words cword _init_completion || return - [ "$prev" = -f ] && _filedir && return 0 - [[ "$cur" == -* ]] && COMPREPLY=( -f ) && return 0 + [[ $prev == -f ]] && _filedir && return 0 + [[ $cur == -* ]] && COMPREPLY=( -f ) && return 0 local db set -- "${words[@]}" - while [ $# -gt 0 ]; do - if [ "$1" = -f ]; then + while [[ $# -gt 0 ]]; do + if [[ $1 == -f ]]; then shift ; db=$1 ; break fi shift 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^^}" ) ) } && diff --git a/doc/styleguide.txt b/doc/styleguide.txt index 76b616ef..0f7ec254 100644 --- a/doc/styleguide.txt +++ b/doc/styleguide.txt @@ -29,13 +29,8 @@ doesn't confuse editors as bad as the latter, and is concise enough. [[ ]] vs [ ] ---------------- -Use [[ ]] instead of [ ] when testing multiple conditions. [ ] is fine -for single conditions where the syntax works. Rationale: [[ ]] has -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. +Always use [[ ]] instead of [ ]. Rationale: the former is less error +prone, more featureful, and slightly faster. Line wrapping ------------- |