Skip to content

Commit 9fb3da2

Browse files
committed
Reduce ShellCheck errors in completion directory
1 parent b6f62a4 commit 9fb3da2

14 files changed

+65
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# shellcheck shell=bash
2+
13
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# shellcheck shell=bash
22

33
if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
4+
# shellcheck disable=SC1090
45
source "$_"
56
fi
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck shell=bash
2+
13
_log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
24
Please disable this completion and use the instructions from "drush" developers instead.'

completion/available/fabric.completion.bash

+7-6
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
4141
# Set command to get time of last file modification as seconds since Epoch
4242
case "$OSTYPE" in
4343
'darwin'* | 'freebsd'*)
44-
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
44+
__FAB_COMPLETION_MTIME_COMMAND=(stat -f '%m')
4545
;;
4646
*)
47-
__FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'"
47+
__FAB_COMPLETION_MTIME_COMMAND=(stat -c '%Y')
4848
;;
4949
esac
5050

5151
#
5252
# Get time of last fab cache file modification as seconds since Epoch
5353
#
5454
function __fab_chache_mtime() {
55-
${__FAB_COMPLETION_MTIME_COMMAND} \
55+
"${__FAB_COMPLETION_MTIME_COMMAND[@]}" \
5656
$FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
5757
}
5858

@@ -62,10 +62,10 @@ function __fab_chache_mtime() {
6262
function __fab_fabfile_mtime() {
6363
local f="fabfile"
6464
if [[ -e "$f.py" ]]; then
65-
${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr
65+
"${__FAB_COMPLETION_MTIME_COMMAND[@]}" "$f.py" | xargs -n 1 expr
6666
else
6767
# Suppose that it's a fabfile dir
68-
find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
68+
find "$f"/*.py -exec "${__FAB_COMPLETION_MTIME_COMMAND[@]}" {} + \
6969
| xargs -n 1 expr | sort -n -r | head -1
7070
fi
7171
}
@@ -85,9 +85,10 @@ function __fab_completion() {
8585
case "${cur}" in
8686
-*)
8787
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
88-
export __FAB_COMPLETION_LONG_OPT=$(
88+
__FAB_COMPLETION_LONG_OPT=$(
8989
fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u
9090
)
91+
export __FAB_COMPLETION_LONG_OPT
9192
fi
9293
opts="${__FAB_COMPLETION_LONG_OPT}"
9394
;;

completion/available/gradle.completion.bash

+20-18
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@ function __gradle-set-project-root-dir() {
3131

3232
__gradle-init-cache-dir() {
3333
cache_dir="$HOME/.gradle/completion"
34-
mkdir -p $cache_dir
34+
mkdir -p "$cache_dir"
3535
}
3636

3737
__gradle-set-build-file() {
3838
# Look for default build script in the settings file (settings.gradle by default)
3939
# Otherwise, default is the file 'build.gradle' in the current directory.
4040
gradle_build_file="$project_root_dir/build.gradle"
4141
if [[ -f "$project_root_dir/settings.gradle" ]]; then
42-
local build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
42+
local build_file_name
43+
build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
4344
| sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")
4445
gradle_build_file="$project_root_dir/${build_file_name:-build.gradle}"
4546
fi
4647
}
4748

4849
__gradle-set-cache-name() {
4950
# Cache name is constructed from the absolute path of the build file.
50-
cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g')
51+
cache_name=$(echo "$gradle_build_file" | sed -e 's/\//_/g')
5152
}
5253

5354
__gradle-set-files-checksum() {
@@ -63,13 +64,14 @@ __gradle-set-files-checksum() {
6364

6465
__gradle-generate-script-cache() {
6566
# Invalidate cache after 3 weeks by default
66-
local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
67-
local script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"}
67+
local cache_ttl_mins script_exclude_pattern gradle_build_scripts
68+
cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
69+
script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"}
6870

69-
if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2> /dev/null) ]]; then
71+
if [[ ! $(find "$cache_dir/$cache_name" -mmin -"$cache_ttl_mins" 2> /dev/null) ]]; then
7072
# Cache all Gradle scripts
71-
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2> /dev/null | grep -E -v "$script_exclude_pattern")
72-
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
73+
gradle_build_scripts=$(find "$project_root_dir" -type f -name "*.gradle" -o -name "*.gradle.kts" 2> /dev/null | grep -E -v "$script_exclude_pattern")
74+
printf "%s\n" "${gradle_build_scripts[@]}" > "$cache_dir/$cache_name"
7375
fi
7476
}
7577

@@ -179,10 +181,10 @@ __gradle-generate-tasks-cache() {
179181
# Run gradle to retrieve possible tasks and cache.
180182
# Reuse Gradle Daemon if IDLE but don't start a new one.
181183
local gradle_tasks_output
182-
if [[ ! -z "$($gradle_cmd --status 2> /dev/null | grep IDLE)" ]]; then
183-
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --daemon -q tasks --all)"
184+
if [[ -n "$("$gradle_cmd" --status 2> /dev/null | grep IDLE)" ]]; then
185+
gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --daemon -q tasks --all)"
184186
else
185-
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)"
187+
gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --no-daemon -q tasks --all)"
186188
fi
187189
local output_line
188190
local task_description
@@ -209,12 +211,12 @@ __gradle-generate-tasks-cache() {
209211
local -a implicit_tasks=()
210212
implicit_tasks=($(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort)))
211213
for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
212-
gradle_all_tasks+=($task)
214+
gradle_all_tasks+=("$task")
213215
done
214216
fi
215217

216-
printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum
217-
echo $gradle_files_checksum > $cache_dir/$cache_name.md5
218+
printf "%s\n" "${gradle_all_tasks[@]}" > "$cache_dir/$gradle_files_checksum"
219+
echo "$gradle_files_checksum" > "$cache_dir/$cache_name.md5"
218220
}
219221

220222
__gradle-completion-init() {
@@ -263,20 +265,20 @@ _gradle() {
263265

264266
# The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
265267
if [[ -f $cache_dir/$cache_name.md5 ]]; then
266-
local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
268+
local cached_checksum="$(cat "$cache_dir/$cache_name.md5")"
267269
local -a cached_tasks
268270
if [[ -z $cur ]]; then
269-
cached_tasks=($(cat $cache_dir/$cached_checksum))
271+
cached_tasks=($(cat "$cache_dir/$cached_checksum"))
270272
else
271-
cached_tasks=($(grep "^$cur" $cache_dir/$cached_checksum))
273+
cached_tasks=($(grep "^$cur" "$cache_dir/$cached_checksum"))
272274
fi
273275
COMPREPLY=($(compgen -W "${cached_tasks[*]}" -- "$cur"))
274276
else
275277
__gradle-notify-tasks-cache-build
276278
fi
277279

278280
# Regenerate tasks cache in the background
279-
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then
281+
if [[ $gradle_files_checksum != "$(cat "$cache_dir/$cache_name.md5")" || ! -f "$cache_dir/$gradle_files_checksum" ]]; then
280282
$(__gradle-generate-tasks-cache 1>&2 2> /dev/null &)
281283
fi
282284
else
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck shell=bash
2+
13
_log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
24
Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# shellcheck shell=bash
2+
3+
# shellcheck disable=SC1090
14
_command_exists minishift && source <(minishift completion bash)
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# shellcheck shell=bash
2+
3+
# shellcheck disable=SC1090
14
_command_exists oc && source <(oc completion bash)
+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# shellcheck shell=bash
22

33
if _command_exists pew; then
4+
# shellcheck disable=SC1090
45
source "$(pew shell_config)"
56
fi
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/usr/bin/env bash
1+
# shellcheck shell=bash
22
# Bash completion support for RVM.
33
# Source: https://rvm.io/workflow/completion
44

5-
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
5+
# shellcheck disable=SC2086
6+
[[ -r "$rvm_path/scripts/completion" ]] && . "$rvm_path/scripts/completion"
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck shell=bash
2+
13
_log_warning 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license.
24
Please disable this completion and use the instructions from "todo.txt-cli" developers instead.'

completion/available/travis.completion.bash

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
if _command_exists travis; then
44
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]; then
5+
# shellcheck disable=SC1090
56
source "${__TRAVIS_COMPLETION_SCRIPT}"
67
fi
78
unset __TRAVIS_COMPLETION_SCRIPT

completion/available/vagrant.completion.bash

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
# shellcheck shell=bash
22

33
# (The MIT License)
44
#
@@ -26,21 +26,21 @@ __pwdln() {
2626
pwdmod="${PWD}/"
2727
itr=0
2828
until [[ -z "$pwdmod" ]]; do
29-
itr=$(($itr + 1))
29+
itr=$((itr + 1))
3030
pwdmod="${pwdmod#*/}"
3131
done
32-
echo -n $(($itr - 1))
32+
echo -n $((itr - 1))
3333
}
3434

3535
__vagrantinvestigate() {
36-
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ]; then
36+
if [ -f "${PWD}/.vagrant" ] || [ -d "${PWD}/.vagrant" ]; then
3737
echo "${PWD}/.vagrant"
3838
return 0
3939
else
4040
pwdmod2="${PWD}"
4141
for ((i = 2; i <= $(__pwdln); i++)); do
4242
pwdmod2="${pwdmod2%/*}"
43-
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ]; then
43+
if [ -f "${pwdmod2}/.vagrant" ] || [ -d "${pwdmod2}/.vagrant" ]; then
4444
echo "${pwdmod2}/.vagrant"
4545
return 0
4646
fi
@@ -54,12 +54,12 @@ _vagrant() {
5454
prev="${COMP_WORDS[COMP_CWORD - 1]}"
5555
commands="box cloud destroy global-status halt help hostmanager init login package plugin port powershell provision push rdp reload resume scp snapshot ssh ssh-config status suspend up upload validate vbguest version winrm winrm-config"
5656

57-
if [ $COMP_CWORD == 1 ]; then
57+
if [ "$COMP_CWORD" == 1 ]; then
5858
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
5959
return 0
6060
fi
6161

62-
if [ $COMP_CWORD == 2 ]; then
62+
if [ "$COMP_CWORD" == 2 ]; then
6363
case "$prev" in
6464
"init")
6565
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
@@ -69,7 +69,7 @@ _vagrant() {
6969
"up")
7070
vagrant_state_file=$(__vagrantinvestigate) || return 1
7171
if [[ -d $vagrant_state_file ]]; then
72-
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
72+
vm_list=$(find "$vagrant_state_file/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
7373
fi
7474
local up_commands="--no-provision"
7575
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
@@ -78,9 +78,9 @@ _vagrant() {
7878
"ssh" | "provision" | "reload" | "halt" | "suspend" | "resume" | "ssh-config")
7979
vagrant_state_file=$(__vagrantinvestigate) || return 1
8080
if [[ -f $vagrant_state_file ]]; then
81-
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
81+
running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
8282
else
83-
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
83+
running_vm_list=$(find "$vagrant_state_file" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
8484
fi
8585
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
8686
return 0
@@ -108,7 +108,7 @@ _vagrant() {
108108
esac
109109
fi
110110

111-
if [ $COMP_CWORD == 3 ]; then
111+
if [ "$COMP_CWORD" == 3 ]; then
112112
action="${COMP_WORDS[COMP_CWORD - 2]}"
113113
case "$action" in
114114
"up")
@@ -120,7 +120,8 @@ _vagrant() {
120120
"box")
121121
case "$prev" in
122122
"remove" | "repackage")
123-
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
123+
local box_list
124+
box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
124125
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
125126
return 0
126127
;;
@@ -136,13 +137,14 @@ _vagrant() {
136137
esac
137138
fi
138139

139-
if [ $COMP_CWORD == 4 ]; then
140+
if [ "$COMP_CWORD" == 4 ]; then
140141
action="${COMP_WORDS[COMP_CWORD - 3]}"
141142
prev="${COMP_WORDS[COMP_CWORD - 2]}"
142143
case "$action" in
143144
"snapshot")
144145
if [ "$prev" == "restore" ]; then
145-
local snapshot_list="$(vagrant snapshot list ${cur} 2> /dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
146+
local snapshot_list
147+
snapshot_list="$(vagrant snapshot list ${cur} 2> /dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
146148
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
147149
return 0
148150
fi
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# shellcheck shell=bash
2+
13
_log_warning 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license.
24
Please disable this completion and use the instructions from "virsh" developers instead.'

0 commit comments

Comments
 (0)