Skip to content

Commit 29015c7

Browse files
committed
lots of little fixes because I screwed up the clean_files.txt and missed unlinted completions.
1 parent b6f62a4 commit 29015c7

14 files changed

+107
-63
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# shellcheck shell=bash
12
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'

completion/available/defaults.completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# shellcheck shell=bash
2+
# shellcheck disable=SC1090
23

34
if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
45
source "$_"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# shellcheck shell=bash
12
_log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
23
Please disable this completion and use the instructions from "drush" developers instead.'

completion/available/fabric.completion.bash

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ case "$OSTYPE" in
4444
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
4545
;;
4646
*)
47+
# shellcheck disable=SC2089
4748
__FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'"
4849
;;
4950
esac
@@ -52,6 +53,7 @@ esac
5253
# Get time of last fab cache file modification as seconds since Epoch
5354
#
5455
function __fab_chache_mtime() {
56+
# shellcheck disable=SC2090
5557
${__FAB_COMPLETION_MTIME_COMMAND} \
5658
$FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
5759
}
@@ -62,9 +64,11 @@ function __fab_chache_mtime() {
6264
function __fab_fabfile_mtime() {
6365
local f="fabfile"
6466
if [[ -e "$f.py" ]]; then
67+
# shellcheck disable=SC2090
6568
${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr
6669
else
6770
# Suppose that it's a fabfile dir
71+
# shellcheck disable=SC2086,SC2090,SC2038
6872
find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
6973
| xargs -n 1 expr | sort -n -r | head -1
7074
fi
@@ -79,15 +83,16 @@ function __fab_completion() {
7983

8084
# Variables to hold the current word and possible matches
8185
local cur="${COMP_WORDS[COMP_CWORD]}"
82-
local opts=()
86+
local opts
8387

8488
# Generate possible matches and store them in variable "opts"
8589
case "${cur}" in
8690
-*)
8791
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
88-
export __FAB_COMPLETION_LONG_OPT=$(
92+
__FAB_COMPLETION_LONG_OPT=$(
8993
fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u
9094
)
95+
export __FAB_COMPLETION_LONG_OPT
9196
fi
9297
opts="${__FAB_COMPLETION_LONG_OPT}"
9398
;;
@@ -124,6 +129,7 @@ function __fab_completion() {
124129
esac
125130

126131
# Set possible completions
127-
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
132+
COMPREPLY=()
133+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${opts}" -- "${cur}")
128134
}
129135
complete -o default -o nospace -F __fab_completion fab

completion/available/gradle.completion.bash

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
# Bash breaks words on : by default. Subproject tasks have ':'
2424
# Avoid inaccurate completions for subproject tasks
25-
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
25+
# shellcheck disable=SC2001
26+
COMP_WORDBREAKS="$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')"
2627

2728
function __gradle-set-project-root-dir() {
2829
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
@@ -31,31 +32,32 @@ function __gradle-set-project-root-dir() {
3132

3233
__gradle-init-cache-dir() {
3334
cache_dir="$HOME/.gradle/completion"
34-
mkdir -p $cache_dir
35+
mkdir -p "$cache_dir"
3536
}
3637

3738
__gradle-set-build-file() {
3839
# Look for default build script in the settings file (settings.gradle by default)
3940
# Otherwise, default is the file 'build.gradle' in the current directory.
4041
gradle_build_file="$project_root_dir/build.gradle"
4142
if [[ -f "$project_root_dir/settings.gradle" ]]; then
42-
local build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
43+
local build_file_name
44+
build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
4345
| sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")
4446
gradle_build_file="$project_root_dir/${build_file_name:-build.gradle}"
4547
fi
4648
}
4749

4850
__gradle-set-cache-name() {
4951
# Cache name is constructed from the absolute path of the build file.
50-
cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g')
52+
cache_name=$(echo "$gradle_build_file" | sed -e 's/\//_/g')
5153
}
5254

5355
__gradle-set-files-checksum() {
5456
# Cache MD5 sum of all Gradle scripts and modified timestamps
5557
if _command_exists md5; then
56-
gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2> /dev/null)")
58+
gradle_files_checksum=$(md5 -q -s "$(xargs ls -o < "$cache_dir/$cache_name" 2> /dev/null)")
5759
elif _command_exists md5sum; then
58-
gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2> /dev/null | md5sum | awk '{print $1}')
60+
gradle_files_checksum=$(xargs ls -o < "$cache_dir/$cache_name" 2> /dev/null | md5sum | awk '{print $1}')
5961
else
6062
echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH"
6163
fi
@@ -66,10 +68,11 @@ __gradle-generate-script-cache() {
6668
local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
6769
local 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+
local gradle_build_scripts
74+
gradle_build_scripts=$(find "$project_root_dir" -type f -name "*.gradle" -o -name "*.gradle.kts" 2> /dev/null | grep -E -v "$script_exclude_pattern")
75+
printf "%s\n" "${gradle_build_scripts[@]}" > "$cache_dir/$cache_name"
7376
fi
7477
}
7578

@@ -115,7 +118,8 @@ __gradle-long-options() {
115118
--system-prop - Set a system property
116119
--version - Prints Gradle version info
117120
--warn - Log warnings and errors only"
118-
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
121+
COMPREPLY=()
122+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
119123
}
120124

121125
__gradle-properties() {
@@ -130,7 +134,8 @@ __gradle-properties() {
130134
-Dorg.gradle.parallel= - Set true to enable parallel project builds (incubating)
131135
-Dorg.gradle.parallel.intra= - Set true to enable intra-project parallel builds (incubating)
132136
-Dorg.gradle.workers.max= - Set the number of workers Gradle is allowed to use"
133-
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
137+
COMPREPLY=()
138+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
134139
return 0
135140
}
136141

@@ -156,7 +161,8 @@ __gradle-short-options() {
156161
-I - Specifies an initialization script
157162
-P - Sets a project property of the root project
158163
-S - Print out the full (very verbose) stacktrace"
159-
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
164+
COMPREPLY=()
165+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
160166
}
161167

162168
__gradle-notify-tasks-cache-build() {
@@ -179,10 +185,10 @@ __gradle-generate-tasks-cache() {
179185
# Run gradle to retrieve possible tasks and cache.
180186
# Reuse Gradle Daemon if IDLE but don't start a new one.
181187
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)"
188+
if $gradle_cmd --status 2> /dev/null | grep -q IDLE; then
189+
gradle_tasks_output="$($gradle_cmd -b "$gradle_build_file" --daemon -q tasks --all)"
184190
else
185-
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)"
191+
gradle_tasks_output="$($gradle_cmd -b "$gradle_build_file" --no-daemon -q tasks --all)"
186192
fi
187193
local output_line
188194
local task_description
@@ -206,15 +212,17 @@ __gradle-generate-tasks-cache() {
206212

207213
# subproject tasks can be referenced implicitly from root project
208214
if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
209-
local -a implicit_tasks=()
210-
implicit_tasks=($(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort)))
215+
local -a implicit_tasks
216+
while IFS='' read -r line; do
217+
implicit_tasks+=("$line")
218+
done < <(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort))
211219
for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
212-
gradle_all_tasks+=($task)
220+
gradle_all_tasks+=("$task")
213221
done
214222
fi
215223

216-
printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum
217-
echo $gradle_files_checksum > $cache_dir/$cache_name.md5
224+
printf "%s\n" "${gradle_all_tasks[@]}" > "$cache_dir/$gradle_files_checksum"
225+
echo "$gradle_files_checksum" > "$cache_dir/$cache_name.md5"
218226
}
219227

220228
__gradle-completion-init() {
@@ -262,22 +270,23 @@ _gradle() {
262270
__gradle-set-files-checksum
263271

264272
# The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
265-
if [[ -f $cache_dir/$cache_name.md5 ]]; then
266-
local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
273+
if [[ -f "$cache_dir/$cache_name.md5" ]]; then
274+
local cached_checksum
275+
cached_checksum="$(cat "$cache_dir/$cache_name.md5")"
267276
local -a cached_tasks
268277
if [[ -z $cur ]]; then
269-
cached_tasks=($(cat $cache_dir/$cached_checksum))
278+
while IFS='' read -r line; do cached_tasks+=("$line"); done < "$cache_dir/$cached_checksum"
270279
else
271-
cached_tasks=($(grep "^$cur" $cache_dir/$cached_checksum))
280+
while IFS='' read -r line; do cached_tasks+=("$line"); done < <(grep "^$cur" "$cache_dir/$cached_checksum")
272281
fi
273-
COMPREPLY=($(compgen -W "${cached_tasks[*]}" -- "$cur"))
282+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${cached_tasks[*]}" -- "$cur")
274283
else
275284
__gradle-notify-tasks-cache-build
276285
fi
277286

278287
# Regenerate tasks cache in the background
279-
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then
280-
$(__gradle-generate-tasks-cache 1>&2 2> /dev/null &)
288+
if [[ $gradle_files_checksum != "$(cat "$cache_dir/$cache_name.md5")" || ! -f "$cache_dir/$gradle_files_checksum" ]]; then
289+
"$(__gradle-generate-tasks-cache 1>&2 2> /dev/null &)"
281290
fi
282291
else
283292
# Default tasks available outside Gradle projects
@@ -293,15 +302,16 @@ projects - Displays the sub-projects of root project.
293302
properties - Displays the properties of root project.
294303
tasks - Displays the tasks runnable from root project.
295304
wrapper - Generates Gradle wrapper files."
296-
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
305+
COMPREPLY=()
306+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${args}" -- "${cur}")
297307
fi
298308
fi
299309

300310
IFS="$OLDIFS"
301311

302312
# Remove description ("[:space:]" and after) if only one possibility
303313
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
304-
COMPREPLY=(${COMPREPLY[0]%% *})
314+
COMPREPLY=("${COMPREPLY[0]%% *}")
305315
fi
306316

307317
return 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
# shellcheck shell=bash
12
_log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
23
Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# shellcheck shell=bash
2+
# shellcheck disable=SC1090
13
_command_exists minishift && source <(minishift completion bash)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# shellcheck shell=bash
2+
# shellcheck disable=SC1090
13
_command_exists oc && source <(oc completion bash)

completion/available/pew.completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# shellcheck shell=bash
2+
# shellcheck disable=SC1090
23

34
if _command_exists pew; then
45
source "$(pew shell_config)"
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/usr/bin/env bash
2-
# Bash completion support for RVM.
1+
# shellcheck shell=bash
2+
# shellcheck disable=SC2154,SC1091
3+
# Bash completion support for RVM.
34
# Source: https://rvm.io/workflow/completion
45

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

completion/available/travis.completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# shellcheck shell=bash
2+
# shellcheck disable=SC1090
23

34
if _command_exists travis; then
45
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]; then

0 commit comments

Comments
 (0)