Skip to content

Commit a6cdab2

Browse files
author
Ira Abramov
committed
Merge branch 'master' into ira/pre-commit-cleanup
* master: (41 commits) no need to test so many versions, just the newest and oldest, I think? First attempt: just a naiive upgrade of BATS you go "quote-TOAH" on that thang! ironing this odd lint problem ironing this odd lint problem Allow setting git current user and add a default icon shfmt and shellcheck, docker-compose.completion is ready shfmt and shellcheck, dirs.completion is ready some compgen tricks are just too complex to write "by the rules" also check on latest ubuntu fixing plugins/available/sudo.plugin.bash fixing plugins/available/thefuck.plugin.bash fixing plugins/available/virtualenv.plugin.bash fixing plugins/available/z_autoenv.plugin.bash fixing bundler fixing salt fixing gradle fixing docker-compose.plugin.bash I guess this needs to be fixed to pass the tests... Start checking one newer macos, the old versions are getting irrelevant ...
2 parents 2279401 + 0cfc448 commit a6cdab2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2443
-2242
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
bats-test:
88
strategy:
99
matrix:
10-
os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-11]
10+
os: [ubuntu-20.04, ubuntu-24.04, macos-14]
1111

1212
runs-on: ${{ matrix.os }}
1313

@@ -62,3 +62,21 @@ jobs:
6262
run: python3 -m pip install -r test/lint-requirements.txt
6363
- name: Run lint
6464
run: ./lint_clean_files.sh
65+
66+
lint-differential:
67+
runs-on: ubuntu-latest
68+
69+
permissions:
70+
security-events: write
71+
72+
steps:
73+
- name: Repository checkout
74+
uses: actions/checkout@v4
75+
with:
76+
fetch-depth: 0
77+
78+
- id: ShellCheck
79+
name: Differential ShellCheck
80+
uses: redhat-plumbers-in-action/differential-shellcheck@v5
81+
with:
82+
token: ${{ secrets.GITHUB_TOKEN }}

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[submodule "test_lib/bats-core"]
22
path = test_lib/bats-core
33
url = https://github.com/bats-core/bats-core
4-
branch = tags/v1.2.0
4+
branch = tags/v1.9.0
55
[submodule "test_lib/bats-support"]
66
path = test_lib/bats-support
77
url = https://github.com/bats-core/bats-support
88
branch = tags/v0.3.0
99
[submodule "test_lib/bats-assert"]
1010
path = test_lib/bats-assert
1111
url = https://github.com/bats-core/bats-assert
12-
branch = tags/v2.0.0
12+
branch = tags/v2.1.0
1313
[submodule "test_lib/bats-file"]
1414
path = test_lib/bats-file
1515
url = https://github.com/bats-core/bats-file
16-
branch = tags/v0.3.0
16+
branch = tags/v0.4.0

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ repos:
2020
- id: git-check # Configure in .gitattributes
2121
- id: shellcheck
2222
- id: shfmt
23-
exclude: ".bats$"
2423
- repo: https://github.com/Lucas-C/pre-commit-hooks
2524
rev: v1.1.7
2625
hooks:

clean_files.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ completion/available/awless.completion.bash
3939
completion/available/awscli.completion.bash
4040
completion/available/bash-it.completion.bash
4141
completion/available/brew.completion.bash
42+
completion/available/bundler.completion.bash
43+
completion/available/capistrano.completion.bash
4244
completion/available/cargo.completion.bash
4345
completion/available/composer.completion.bash
4446
completion/available/conda.completion.bash
4547
completion/available/consul.completion.bash
4648
completion/available/dart.completion.bash
49+
completion/available/dirs.completion.bash
4750
completion/available/django.completion.bash
4851
completion/available/dmidecode.completion.bash
52+
completion/available/docker-compose.completion.bash
4953
completion/available/docker-machine.completion.bash
5054
completion/available/docker.completion.bash
5155
completion/available/dotnet.completion.bash
@@ -75,6 +79,7 @@ completion/available/pip3.completion.bash
7579
completion/available/pipenv.completion.bash
7680
completion/available/pipx.completion.bash
7781
completion/available/rustup.completion.bash
82+
completion/available/salt.completion.bash
7883
completion/available/sdkman.completion.bash
7984
completion/available/system.completion.bash
8085
completion/available/vault.completion.bash
@@ -95,12 +100,14 @@ plugins/available/cmd-returned-notify.plugin.bash
95100
plugins/available/colors.plugin.bash
96101
plugins/available/direnv.plugin.bash
97102
plugins/available/dirs.plugin.bash
103+
plugins/available/docker-compose.plugin.bash
98104
plugins/available/docker-machine.plugin.bash
99105
plugins/available/gif.plugin.bash
100106
plugins/available/git-subrepo.plugin.bash
101107
plugins/available/git.plugin.bash
102108
plugins/available/go.plugin.bash
103109
plugins/available/goenv.plugin.bash
110+
plugins/available/gradle.plugin.bash
104111
plugins/available/history-eternal.plugin.bash
105112
plugins/available/history-search.plugin.bash
106113
plugins/available/history-substring-search.plugin.bash
@@ -126,18 +133,16 @@ plugins/available/pyenv.plugin.bash
126133
plugins/available/python.plugin.bash
127134
plugins/available/rbenv.plugin.bash
128135
plugins/available/ruby.plugin.bash
136+
plugins/available/sudo.plugin.bash
129137
plugins/available/textmate.plugin.bash
138+
plugins/available/thefuck.plugin.bash
130139
plugins/available/todo.plugin.bash
131140
plugins/available/url.plugin.bash
141+
plugins/available/virtualenv.plugin.bash
132142
plugins/available/xterm.plugin.bash
143+
plugins/available/z_autoenv.plugin.bash
133144
plugins/available/zoxide.plugin.bash
134145

135-
# tests
136-
#
137-
test/completion/aliases.completion.bats
138-
test/run
139-
test/test_helper.bash
140-
141146
# themes
142147
#
143148
themes/90210
@@ -159,6 +164,7 @@ themes/easy
159164
themes/elixr
160165
themes/essential
161166
themes/githelpers.theme.bash
167+
themes/gitline
162168
themes/inretio
163169
themes/lambda
164170
themes/modern

completion/available/bundler.completion.bash

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#! bash
1+
# shellcheck shell=bash
2+
# shellcheck disable=SC2207
23
# bash completion for the `bundle` command.
34
#
45
# Copyright (c) 2008 Daniel Luz
@@ -146,6 +147,7 @@ __bundle() {
146147
options+=(local. mirror.)
147148
# Override $IFS for completion to work
148149
local IFS=$'\n'
150+
# shellcheck disable=SC2016
149151
COMPREPLY=($(compgen -W '${options[@]}' -- "$cur"))
150152
return
151153
;;
@@ -160,19 +162,21 @@ __bundle() {
160162
exec)
161163
if [[ $COMP_CWORD -eq $bundle_command_index ]]; then
162164
# Figure out Bundler's binaries dir
163-
local bundler_bin=$(__bundle_exec_ruby 'puts Bundler.bundle_path + "bin"')
165+
local bundler_bin
166+
bundler_bin=$(__bundle_exec_ruby 'puts Bundler.bundle_path + "bin"')
164167
if [[ -d $bundler_bin ]]; then
165-
local binaries=("$bundler_bin"/*)
168+
local binaries
169+
binaries=("$bundler_bin"/*)
166170
# If there are binaries, strip directory name and use them
167-
[[ -f "$binaries" ]] && options="${binaries[@]##*/}"
171+
[[ -f "${binaries[0]}" ]] && options=("${binaries[@]##*/}")
168172
else
169173
# No binaries found; use full command completion
170174
COMPREPLY=($(compgen -c -- "$cur"))
171175
return
172176
fi
173177
else
174178
local _RUBY_COMMAND_PREFIX=("${bundle_bin[@]}" exec)
175-
_command_offset $bundle_command_index
179+
_command_offset "$bundle_command_index"
176180
return
177181
fi
178182
;;
@@ -183,7 +187,7 @@ __bundle() {
183187
return
184188
;;
185189
-t | --test)
186-
options="minitest rspec"
190+
options=("minitest" "rspec")
187191
;;
188192
esac
189193
;;
@@ -201,7 +205,7 @@ __bundle() {
201205
viz)
202206
case $prev in
203207
-F | --format)
204-
options="dot jpg png svg"
208+
options=("dot" "jpg" "png" "svg")
205209
;;
206210
-W | --without)
207211
__bundle_complete_groups
@@ -216,7 +220,7 @@ __bundle() {
216220

217221
__bundle_get_command() {
218222
local i
219-
for ((i = 1; i < $COMP_CWORD; ++i)); do
223+
for ((i = 1; i < COMP_CWORD; ++i)); do
220224
local arg=${COMP_WORDS[$i]}
221225

222226
case $arg in
@@ -248,7 +252,8 @@ __bundle_complete_groups() {
248252
local cur_group=${cur##*[ :]}
249253
# All groups written before
250254
local prefix=${cur%"$cur_group"}
251-
local groups=$(__bundle_exec_ruby 'puts Bundler.definition.dependencies.map(&:groups).reduce(:|).map(&:to_s)')
255+
local groups
256+
groups=$(__bundle_exec_ruby 'puts Bundler.definition.dependencies.map(&:groups).reduce(:|).map(&:to_s)')
252257
if [[ ! $groups ]]; then
253258
COMPREPLY=()
254259
return
@@ -269,7 +274,7 @@ __bundle_complete_groups() {
269274
# Runs a Ruby script with Bundler loaded.
270275
# Results may be cached.
271276
__bundle_exec_ruby() {
272-
local bundle_bin=(${bundle_bin[@]:-bundle})
277+
local bundle_bin=("${bundle_bin[@]:-bundle}")
273278
# Lockfile is inferred here, and might not be correct (for example, when
274279
# running on a subdirectory). However, a wrong file path won't be a
275280
# cadastrophic mistake; it just means the cache won't be invalidated when
@@ -286,10 +291,10 @@ __bundle_exec_ruby() {
286291
$(head -n 1 -- "$cachefile" 2> /dev/null) = "$cache_id_line" ]]; then
287292
tail -n +2 -- "$cachefile"
288293
else
289-
local output=$("${bundle_bin[@]}" exec ruby -e "$@" 2> /dev/null)
290-
if [[ $? -eq 0 ]]; then
294+
local output
295+
if output=$("${bundle_bin[@]}" exec ruby -e "$@" 2> /dev/null); then
291296
(mkdir -p -- "$cachedir" \
292-
&& echo "$cache_id_line"$'\n'"$output" > $cachefile) 2> /dev/null
297+
&& echo "$cache_id_line"$'\n'"$output" > "$cachefile") 2> /dev/null
293298
echo "$output"
294299
fi
295300
fi

completion/available/capistrano.completion.bash

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
#!/usr/bin/env bash
1+
# shellcheck shell=bash
22
# Bash completion support for Capistrano.
33

44
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
55

66
_capcomplete() {
77
if [ -f Capfile ]; then
8-
recent=$(ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1)
8+
# shellcheck disable=SC2012
9+
recent=$(ls -t .cap_tasks~ Capfile ./**/*.cap 2> /dev/null | head -n 1)
910
if [[ $recent != '.cap_tasks~' ]]; then
10-
cap --version | grep 'Capistrano v2.' > /dev/null
11-
if [ $? -eq 0 ]; then
11+
if cap --version | grep -q 'Capistrano v2.'; then
1212
# Capistrano 2.x
1313
cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~
1414
else
1515
# Capistrano 3.x
1616
cap --all --tasks | cut -d " " -f 2 > .cap_tasks~
1717
fi
1818
fi
19-
COMPREPLY=($(compgen -W "$(cat .cap_tasks~)" -- ${COMP_WORDS[COMP_CWORD]}))
19+
# shellcheck disable=SC2207
20+
COMPREPLY=($(compgen -W "$(cat .cap_tasks~)" -- "${COMP_WORDS[COMP_CWORD]}"))
2021
return 0
2122
fi
2223
}

completion/available/dirs.completion.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#!/usr/bin/env bash
1+
# shellcheck shell=bash
22
# Bash completion support for the 'dirs' plugin (commands G, R).
33

44
_dirs-complete() {
55
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
66

77
# parse all defined shortcuts from ~/.dirs
88
if [ -r "$HOME/.dirs" ]; then
9-
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}))
9+
# shellcheck disable=SC2207
10+
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- "${CURRENT_PROMPT}"))
1011
fi
1112

1213
return 0

completion/available/docker-compose.completion.bash

100755100644
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
# shellcheck shell=bash
2+
# shellcheck disable=SC2207
23
#
34

45
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,23 +42,24 @@ __docker_compose_q() {
4142
# Transforms a multiline list of strings into a single line string
4243
# with the words separated by "|".
4344
__docker_compose_to_alternatives() {
44-
local parts=($1)
45+
local parts=("$1")
4546
local IFS='|'
4647
echo "${parts[*]}"
4748
}
4849

4950
# Transforms a multiline list of options into an extglob pattern
5051
# suitable for use in case statements.
5152
__docker_compose_to_extglob() {
52-
local extglob=$(__docker_compose_to_alternatives "$1")
53+
local extglob
54+
extglob=$(__docker_compose_to_alternatives "$1")
5355
echo "@($extglob)"
5456
}
5557

5658
# Determines whether the option passed as the first argument exist on
5759
# the commandline. The option may be a pattern, e.g. `--force|-f`.
5860
__docker_compose_has_option() {
5961
local pattern="$1"
60-
for ((i = 2; i < $cword; ++i)); do
62+
for ((i = 2; i < cword; ++i)); do
6163
if [[ ${words[$i]} =~ ^($pattern)$ ]]; then
6264
return 0
6365
fi
@@ -112,7 +114,8 @@ __docker_compose_complete_services() {
112114

113115
# The services for which at least one running container exists
114116
__docker_compose_complete_running_services() {
115-
local names=$(__docker_compose_services --filter status=running)
117+
local names
118+
names=$(__docker_compose_services --filter status=running)
116119
COMPREPLY=($(compgen -W "$names" -- "$cur"))
117120
}
118121

@@ -193,7 +196,7 @@ _docker_compose_docker_compose() {
193196
_filedir -d
194197
return
195198
;;
196-
$(__docker_compose_to_extglob "$daemon_options_with_args"))
199+
"$(__docker_compose_to_extglob "$daemon_options_with_args")")
197200
return
198201
;;
199202
esac
@@ -278,7 +281,7 @@ _docker_compose_images() {
278281
_docker_compose_kill() {
279282
case "$prev" in
280283
-s)
281-
COMPREPLY=($(compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')"))
284+
COMPREPLY=($(compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo "$cur" | tr '[:lower:]' '[:upper:]')"))
282285
return
283286
;;
284287
esac
@@ -343,7 +346,8 @@ _docker_compose_port() {
343346
}
344347

345348
_docker_compose_ps() {
346-
local key=$(__docker_compose_map_key_of_current_option '--filter')
349+
local key
350+
key=$(__docker_compose_map_key_of_current_option '--filter')
347351
case "$key" in
348352
source)
349353
COMPREPLY=($(compgen -W "build image" -- "${cur##*=}"))
@@ -560,7 +564,8 @@ _docker_compose_version() {
560564
}
561565

562566
_docker_compose() {
563-
local previous_extglob_setting=$(shopt -p extglob)
567+
local previous_extglob_setting
568+
previous_extglob_setting=$(shopt -p extglob)
564569
shopt -s extglob
565570

566571
local commands=(
@@ -624,21 +629,22 @@ _docker_compose() {
624629
local top_level_options=()
625630
local counter=1
626631

627-
while [ $counter -lt $cword ]; do
632+
while [ $counter -lt "$cword" ]; do
628633
case "${words[$counter]}" in
629-
$(__docker_compose_to_extglob "$daemon_boolean_options"))
634+
"$(__docker_compose_to_extglob "$daemon_boolean_options")")
630635
local opt=${words[counter]}
631-
top_level_options+=($opt)
636+
top_level_options+=("$opt")
632637
;;
633-
$(__docker_compose_to_extglob "$daemon_options_with_args"))
638+
"$(__docker_compose_to_extglob "$daemon_options_with_args")")
634639
local opt=${words[counter]}
635640
local arg=${words[++counter]}
636-
top_level_options+=($opt $arg)
641+
top_level_options+=("$opt" "$arg")
637642
;;
638-
$(__docker_compose_to_extglob "$top_level_options_with_args"))
643+
"$(__docker_compose_to_extglob "$top_level_options_with_args")")
639644
((counter++))
640645
;;
641646
-*) ;;
647+
642648
*)
643649
command="${words[$counter]}"
644650
break
@@ -648,7 +654,7 @@ _docker_compose() {
648654
done
649655

650656
local completions_func=_docker_compose_${command//-/_}
651-
_is_function $completions_func && $completions_func
657+
_is_function "$completions_func" && $completions_func
652658

653659
eval "$previous_extglob_setting"
654660
return 0

0 commit comments

Comments
 (0)