# HG changeset patch # User Thomas Arendsen Hein # Date 1138864577 -3600 # Node ID cf930b2452d3156f4ea100e60ccb7cf57c023b22 # Parent 063e04831a0990a147cd09e9885e678d1e9b2b22 Cleanup of spacing in bash_completion diff --git a/contrib/bash_completion b/contrib/bash_completion --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -4,34 +4,34 @@ shopt -s extglob { "$hg" --debug help 2>/dev/null | \ awk 'function command_line(line) { - gsub(/,/, "", line) - gsub(/:.*/, "", line) - split(line, aliases) - command = aliases[1] - delete aliases[1] - print command - for (i in aliases) - if (index(command, aliases[i]) != 1) - print aliases[i] - } - /^list of commands:/ {commands=1} - commands && /^ debug/ {a[i++] = $0; next;} - commands && /^ [^ ]/ {command_line($0)} - /^global options:/ {exit 0} - END {for (i in a) command_line(a[i])}' + gsub(/,/, "", line) + gsub(/:.*/, "", line) + split(line, aliases) + command = aliases[1] + delete aliases[1] + print command + for (i in aliases) + if (index(command, aliases[i]) != 1) + print aliases[i] + } + /^list of commands:/ {commands=1} + commands && /^ debug/ {a[i++] = $0; next;} + commands && /^ [^ ]/ {command_line($0)} + /^global options:/ {exit 0} + END {for (i in a) command_line(a[i])}' } _hg_option_list() { - "$hg" -v help $1 2> /dev/null | \ - awk '/^ *-/ { - for (i = 1; i <= NF; i ++) { + "$hg" -v help $1 2>/dev/null | \ + awk '/^ *-/ { + for (i = 1; i <= NF; i ++) { if (index($i, "-") != 1) - break; + break; print $i; - } - }' + } + }' } @@ -56,29 +56,29 @@ shopt -s extglob _hg_paths() { - local paths="$("$hg" paths 2> /dev/null | sed -e 's/ = .*$//')" - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W '$paths' -- "$cur" )) + local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')" + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) } _hg_repos() { local i - for i in $( compgen -d -- "$cur" ); do - test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i") + for i in $(compgen -d -- "$cur"); do + test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i") done } _hg_status() { - local files="$( "$hg" status -n$1 . 2> /dev/null)" - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -W '$files' -- "$cur" )) + local files="$("$hg" status -n$1 . 2>/dev/null)" + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) } _hg_tags() { - local tags="$("$hg" tags 2> /dev/null | - sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur") ) + local tags="$("$hg" tags 2>/dev/null | + sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')" + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) } # this is "kind of" ugly... @@ -87,7 +87,7 @@ shopt -s extglob local i count=0 local filters="$1" - for (( i=1; $i<=$COMP_CWORD; i++ )); do + for ((i=1; $i<=$COMP_CWORD; i++)); do if [[ "${COMP_WORDS[i]}" != -* ]]; then if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then continue @@ -113,7 +113,7 @@ shopt -s extglob # searching for the command # (first non-option argument that doesn't follow a global option that # receives an argument) - for (( i=1; $i<=$COMP_CWORD; i++ )); do + for ((i=1; $i<=$COMP_CWORD; i++)); do if [[ ${COMP_WORDS[i]} != -* ]]; then if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then cmd="${COMP_WORDS[i]}" @@ -125,7 +125,7 @@ shopt -s extglob if [[ "$cur" == -* ]]; then opts=$(_hg_option_list $cmd) - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur") ) + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) return fi @@ -147,7 +147,7 @@ shopt -s extglob fi # canonicalize command name - cmd=$("$hg" -q help "$cmd" 2> /dev/null | sed -e 's/^hg //; s/ .*//; 1q') + cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q') if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then _hg_tags @@ -191,17 +191,17 @@ shopt -s extglob if [ $count = 1 ]; then _hg_paths fi - _hg_repos + _hg_repos ;; debugindex|debugindexdot) - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.i" -- "$cur" )) + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) ;; debugdata) - COMPREPLY=(${COMPREPLY[@]:-} $( compgen -f -X "!*.d" -- "$cur" )) + COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) ;; esac } -complete -o bashdefault -o default -F _hg hg 2> /dev/null \ +complete -o bashdefault -o default -F _hg hg 2>/dev/null \ || complete -o default -F _hg hg