Merge pull request #11301 from GauthamGoli/bash-shellcheck-fixes-2
Fix `shellcheck` style errors on bash completion file
This commit is contained in:
		
						commit
						d4c131f3f6
					
				@ -180,13 +180,14 @@ module Homebrew
 | 
				
			|||||||
      <<~COMPLETION
 | 
					      <<~COMPLETION
 | 
				
			||||||
        _brew_#{Commands.method_name command}() {
 | 
					        _brew_#{Commands.method_name command}() {
 | 
				
			||||||
          local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					          local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
          case "$cur" in
 | 
					          case "${cur}" in
 | 
				
			||||||
            -*)
 | 
					            -*)
 | 
				
			||||||
              __brewcomp "
 | 
					              __brewcomp "
 | 
				
			||||||
              #{command_options(command).keys.sort.join("\n      ")}
 | 
					              #{command_options(command).keys.sort.join("\n      ")}
 | 
				
			||||||
              "
 | 
					              "
 | 
				
			||||||
              return
 | 
					              return
 | 
				
			||||||
              ;;
 | 
					              ;;
 | 
				
			||||||
 | 
					            *)
 | 
				
			||||||
          esac#{named_completion_string}
 | 
					          esac#{named_completion_string}
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      COMPLETION
 | 
					      COMPLETION
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
__brewcomp_words_include() {
 | 
					__brewcomp_words_include() {
 | 
				
			||||||
  local i=1
 | 
					  local i=1
 | 
				
			||||||
  while [[ "$i" -lt "$COMP_CWORD" ]]
 | 
					  while [[ "${i}" -lt "${COMP_CWORD}" ]]
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
    if [[ "${COMP_WORDS[i]}" = "$1" ]]
 | 
					    if [[ "${COMP_WORDS[i]}" = "$1" ]]
 | 
				
			||||||
    then
 | 
					    then
 | 
				
			||||||
@ -30,12 +30,12 @@ __brewcomp_words_include() {
 | 
				
			|||||||
__brewcomp_prev() {
 | 
					__brewcomp_prev() {
 | 
				
			||||||
  local idx="$((COMP_CWORD - 1))"
 | 
					  local idx="$((COMP_CWORD - 1))"
 | 
				
			||||||
  local prv="${COMP_WORDS[idx]}"
 | 
					  local prv="${COMP_WORDS[idx]}"
 | 
				
			||||||
  while [[ "$prv" = -* ]]
 | 
					  while [[ "${prv}" = -* ]]
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
    (( idx-- ))
 | 
					    (( idx-- ))
 | 
				
			||||||
    prv="${COMP_WORDS[idx]}"
 | 
					    prv="${COMP_WORDS[idx]}"
 | 
				
			||||||
  done
 | 
					  done
 | 
				
			||||||
  echo "$prv"
 | 
					  echo "${prv}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brewcomp() {
 | 
					__brewcomp() {
 | 
				
			||||||
@ -46,12 +46,12 @@ __brewcomp() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  for s in $1
 | 
					  for s in $1
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
    __brewcomp_words_include "$s" && continue
 | 
					    __brewcomp_words_include "${s}" && continue
 | 
				
			||||||
    list="$list$s$sep"
 | 
					    list="${list}${s}${sep}"
 | 
				
			||||||
  done
 | 
					  done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  IFS="$sep"
 | 
					  IFS="${sep}"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$list" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${list}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Don't use __brewcomp() in any of the __brew_complete_foo functions, as
 | 
					# Don't use __brewcomp() in any of the __brew_complete_foo functions, as
 | 
				
			||||||
@ -60,56 +60,56 @@ __brew_complete_formulae() {
 | 
				
			|||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local formulae
 | 
					  local formulae
 | 
				
			||||||
  formulae="$(brew formulae)"
 | 
					  formulae="$(brew formulae)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$formulae" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${formulae}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_casks() {
 | 
					__brew_complete_casks() {
 | 
				
			||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local casks
 | 
					  local casks
 | 
				
			||||||
  casks="$(brew casks)"
 | 
					  casks="$(brew casks)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$casks" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${casks}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_installed_formulae() {
 | 
					__brew_complete_installed_formulae() {
 | 
				
			||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local installed_formulae
 | 
					  local installed_formulae
 | 
				
			||||||
  installed_formulae="$(command ls "$(brew --cellar)" 2>/dev/null)"
 | 
					  installed_formulae="$(command ls "$(brew --cellar)" 2>/dev/null)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$installed_formulae" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${installed_formulae}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_installed_casks() {
 | 
					__brew_complete_installed_casks() {
 | 
				
			||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local installed_casks
 | 
					  local installed_casks
 | 
				
			||||||
  installed_casks="$(command ls "$(brew --caskroom)" 2>/dev/null)"
 | 
					  installed_casks="$(command ls "$(brew --caskroom)" 2>/dev/null)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$installed_casks" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${installed_casks}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_outdated_formulae() {
 | 
					__brew_complete_outdated_formulae() {
 | 
				
			||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local outdated_formulae
 | 
					  local outdated_formulae
 | 
				
			||||||
  outdated_formulae="$(brew outdated --formula --quiet)"
 | 
					  outdated_formulae="$(brew outdated --formula --quiet)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$outdated_formulae" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_formulae}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_outdated_casks() {
 | 
					__brew_complete_outdated_casks() {
 | 
				
			||||||
  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					  local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
  local outdated_casks
 | 
					  local outdated_casks
 | 
				
			||||||
  outdated_casks="$(brew outdated --cask --quiet)"
 | 
					  outdated_casks="$(brew outdated --cask --quiet)"
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$outdated_casks" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_casks}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_tapped() {
 | 
					__brew_complete_tapped() {
 | 
				
			||||||
  local dir taps taplib
 | 
					  local dir taps taplib
 | 
				
			||||||
  taplib="$(brew --repository)/Library/Taps"
 | 
					  taplib="$(brew --repository)/Library/Taps"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for dir in "$taplib"/*/*
 | 
					  for dir in "${taplib}"/*/*
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
    [[ -d "$dir" ]] || continue
 | 
					    [[ -d "${dir}" ]] || continue
 | 
				
			||||||
    dir="${dir#${taplib}/}"
 | 
					    dir="${dir#${taplib}/}"
 | 
				
			||||||
    dir="${dir/homebrew-/}"
 | 
					    dir="${dir/homebrew-/}"
 | 
				
			||||||
    taps="$taps $dir"
 | 
					    taps="${taps} ${dir}"
 | 
				
			||||||
  done
 | 
					  done
 | 
				
			||||||
  __brewcomp "$taps"
 | 
					  __brewcomp "${taps}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__brew_complete_commands() {
 | 
					__brew_complete_commands() {
 | 
				
			||||||
@ -118,13 +118,13 @@ __brew_complete_commands() {
 | 
				
			|||||||
  HOMEBREW_CACHE=$(brew --cache)
 | 
					  HOMEBREW_CACHE=$(brew --cache)
 | 
				
			||||||
  HOMEBREW_REPOSITORY=$(brew --repo)
 | 
					  HOMEBREW_REPOSITORY=$(brew --repo)
 | 
				
			||||||
  # Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
 | 
					  # Do not auto-complete "*instal" or "*uninstal" aliases for "*install" commands.
 | 
				
			||||||
  if [[ -f "$HOMEBREW_CACHE/all_commands_list.txt" ]]
 | 
					  if [[ -f "${HOMEBREW_CACHE}/all_commands_list.txt" ]]
 | 
				
			||||||
  then
 | 
					  then
 | 
				
			||||||
    cmds="$(< "$HOMEBREW_CACHE/all_commands_list.txt" \grep -v instal$)"
 | 
					    cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt" \grep -v instal$)"
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    cmds="$(< "$HOMEBREW_REPOSITORY/completions/internal_commands_list.txt" \grep -v instal$)"
 | 
					    cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt" \grep -v instal$)"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  while read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$cmds" -- "$cur")
 | 
					  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# compopt is only available in newer versions of bash
 | 
					# compopt is only available in newer versions of bash
 | 
				
			||||||
 | 
				
			|||||||
@ -245,7 +245,7 @@ describe Homebrew::Completions do
 | 
				
			|||||||
        expect(completion).to eq <<~COMPLETION
 | 
					        expect(completion).to eq <<~COMPLETION
 | 
				
			||||||
          _brew_missing() {
 | 
					          _brew_missing() {
 | 
				
			||||||
            local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					            local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
            case "$cur" in
 | 
					            case "${cur}" in
 | 
				
			||||||
              -*)
 | 
					              -*)
 | 
				
			||||||
                __brewcomp "
 | 
					                __brewcomp "
 | 
				
			||||||
                --debug
 | 
					                --debug
 | 
				
			||||||
@ -256,6 +256,7 @@ describe Homebrew::Completions do
 | 
				
			|||||||
                "
 | 
					                "
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
                ;;
 | 
					                ;;
 | 
				
			||||||
 | 
					              *)
 | 
				
			||||||
            esac
 | 
					            esac
 | 
				
			||||||
            __brew_complete_formulae
 | 
					            __brew_complete_formulae
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@ -267,7 +268,7 @@ describe Homebrew::Completions do
 | 
				
			|||||||
        expect(completion).to eq <<~COMPLETION
 | 
					        expect(completion).to eq <<~COMPLETION
 | 
				
			||||||
          _brew_update() {
 | 
					          _brew_update() {
 | 
				
			||||||
            local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
					            local cur="${COMP_WORDS[COMP_CWORD]}"
 | 
				
			||||||
            case "$cur" in
 | 
					            case "${cur}" in
 | 
				
			||||||
              -*)
 | 
					              -*)
 | 
				
			||||||
                __brewcomp "
 | 
					                __brewcomp "
 | 
				
			||||||
                --debug
 | 
					                --debug
 | 
				
			||||||
@ -279,6 +280,7 @@ describe Homebrew::Completions do
 | 
				
			|||||||
                "
 | 
					                "
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
                ;;
 | 
					                ;;
 | 
				
			||||||
 | 
					              *)
 | 
				
			||||||
            esac
 | 
					            esac
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        COMPLETION
 | 
					        COMPLETION
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,7 +1,7 @@
 | 
				
			|||||||
.\" generated with Ronn/v0.7.3
 | 
					.\" generated with Ronn/v0.7.3
 | 
				
			||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
 | 
					.\" http://github.com/rtomayko/ronn/tree/0.7.3
 | 
				
			||||||
.
 | 
					.
 | 
				
			||||||
.TH "BREW" "1" "April 2021" "Homebrew" "brew"
 | 
					.TH "BREW" "1" "May 2021" "Homebrew" "brew"
 | 
				
			||||||
.
 | 
					.
 | 
				
			||||||
.SH "NAME"
 | 
					.SH "NAME"
 | 
				
			||||||
\fBbrew\fR \- The Missing Package Manager for macOS (or Linux)
 | 
					\fBbrew\fR \- The Missing Package Manager for macOS (or Linux)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user