diff --git a/bash_completion b/bash_completion index 9732c102..0cf707d7 100644 --- a/bash_completion +++ b/bash_completion @@ -184,7 +184,7 @@ _upvar() # Assign variables one scope above the caller -# Usage: local varname [varname ...] && +# Usage: local varname [varname ...] && # _upvars [-v varname value] | [-aN varname [value ...]] ... # Available OPTIONS: # -aN Assign next N values to varname as array @@ -208,7 +208,7 @@ _upvars() "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2 return 1; } # Assign array of -aN elements - [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && + [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\ "\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; } ;; @@ -244,7 +244,7 @@ __reassemble_comp_words_by_ref() # Exclude only those characters, which were really included exclude="${1//[^$COMP_WORDBREAKS]}" fi - + # Default to cword unchanged eval $3=$COMP_CWORD # Are characters excluded which were former included? @@ -355,7 +355,7 @@ __get_cword_at_cursor_by_ref() # cword Return cword via $cword # # Available OPTIONS: -# -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be +# -n EXCLUDE Characters out of $COMP_WORDBREAKS which should NOT be # considered word breaks. This is useful for things like scp # where we want to return host:path and not only path, so we # would pass the colon (:) as -n option in this case. @@ -383,7 +383,7 @@ _get_comp_words_by_ref() w) vwords=$OPTARG ;; esac done - while [[ $# -ge $OPTIND ]]; do + while [[ $# -ge $OPTIND ]]; do case ${!OPTIND} in cur) vcur=cur ;; prev) vprev=prev ;; @@ -399,7 +399,7 @@ _get_comp_words_by_ref() [[ $vcur ]] && { upvars+=("$vcur" ); upargs+=(-v $vcur "$cur" ); } [[ $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword"); } - [[ $vprev && $cword -ge 1 ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev + [[ $vprev && $cword -ge 1 ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev "${words[cword - 1]}"); } [[ $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords "${words[@]}"); } @@ -479,7 +479,7 @@ _get_cword() # @deprecated Use `_get_comp_words_by_ref cur prev' instead # @see _get_comp_words_by_ref() # -_get_pword() +_get_pword() { if [[ $COMP_CWORD -ge 1 ]]; then _get_cword "${@:-}" 1 @@ -617,7 +617,7 @@ _split_longopt() } # Complete variables. -# @return True (0) if variables were completed, +# @return True (0) if variables were completed, # False (> 0) if not. _variables() { @@ -642,7 +642,7 @@ _variables() # -o XSPEC Passed to _filedir as first arg for other output redirections # -i XSPEC Passed to _filedir as first arg for stdin redirections # -s Split long options with _split_longopt, implies -n = -# @return True (0) if completion needs further processing, +# @return True (0) if completion needs further processing, # False (> 0) no further processing is necessary. # _init_completion() @@ -914,7 +914,7 @@ _ncpus() } # Perform tilde (~) completion -# @return True (0) if completion needs further processing, +# @return True (0) if completion needs further processing, # False (> 0) if tilde is followed by a valid username, completions # are put in COMPREPLY and no further processing is necessary. _tilde() @@ -951,7 +951,7 @@ _tilde() # ~foo/$HOME /home/foo/$HOME # ~foo/a b /home/foo/a b # ~foo/* /home/foo/* -# +# # @param $1 Name of variable (not the value of the variable) to expand __expand_tilde_by_ref() { @@ -966,7 +966,7 @@ __expand_tilde_by_ref() # becomes "b". Single quotes prevent eval. # +-----1----+ +---2----+ eval $1="${!1/%\/*}"/'${!1#*/}' - else + else # No, $1 doesn't contain slash eval $1="${!1}" fi