Skip to content

Commit 1c3cbf7

Browse files
authored
Delete .shellcheckrc (#1947)
* CI: disable Ubuntu 16.04 as it's EOL https://github.blog/changelog/2021-04-29-github-actions-ubuntu-16-04-lts-virtual-environment-will-be-removed-on-september-20-2021/ * main: lint false positive * install: lint * plugins/cmd-returned-notify: don't `export` * plugins/xterm: lint * plugins/git: lint * plugins/goenv: lint * plugins/alias-completion: lint false positives * plugins/alias-completion: fix SC2155, SC2154 Declare `locals` at the top of the function * completion: lint completions using `bash_completion` functions Match the style of the existing code * completion/knife: lint false positives * completion/knife: lint * completion/sdkman: lint * completion/composer: lint * Move `.shellcheckrc` under `themes/` * lib/theme: fix SC2155, SC2154, SC2034 * lib/colors: don't warn on unused variables We assign a large number of variables here and they may or may not be used anywhere else, so disable SC2034 for this file (only). Alsö disable SC2005 as the functions in this file were written before `printf` was invented and have to do some fancy metascripting to get escape sequences interpreted reliably. I’m not smart enough to fix this to use `printf`, so leave it for now. * themes/agnoster: lint * themes: disable SC2154 for colors Each one of these themes will need it’s own fix for SC2154, possibly upstream. Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules. * themes: disable SC2154, fix SC2155 Each one of these themes will need it’s own fix for SC2154, possibly upstream. Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules. * Delete `.shellcheckrc` * remove executable bit
1 parent b48f3fd commit 1c3cbf7

Some content is hidden

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

44 files changed

+183
-126
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
bats-test:
1212
strategy:
1313
matrix:
14-
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15, macos-11.0]
14+
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11.0]
1515

1616
runs-on: ${{ matrix.os }}
1717

.shellcheckrc

-6
This file was deleted.

bash_it.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ for _bash_it_config_file in $CUSTOM; do
114114
if [ -e "${_bash_it_config_file}" ]; then
115115
filename=$(basename "${_bash_it_config_file}")
116116
filename=${filename%*.bash}
117+
# shellcheck disable=SC2034
117118
BASH_IT_LOG_PREFIX="custom: $filename: "
118119
_log_debug "Loading custom file..."
119120
# shellcheck disable=SC1090
@@ -122,7 +123,7 @@ for _bash_it_config_file in $CUSTOM; do
122123
done
123124

124125
unset _bash_it_config_file
125-
if [[ "${PROMPT:-}" ]]; then
126+
if [[ -n "${PROMPT:-}" ]]; then
126127
export PS1="\[""$PROMPT""\]"
127128
fi
128129

completion/available/composer.completion.bash

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ cite "about-completion"
33
about-completion "composer completion"
44

55
function __composer_completion() {
6-
local cur coms opts com
6+
local cur coms opts com words
77
COMPREPLY=()
88
_get_comp_words_by_ref -n : cur words
99

1010
# lookup for command
1111
for word in "${words[@]:1}"; do
12-
if [[ $word != -* ]]; then
13-
com=$word
12+
if [[ "${word}" != -* ]]; then
13+
com="${word}"
1414
break
1515
fi
1616
done
@@ -19,7 +19,7 @@ function __composer_completion() {
1919
if [[ ${cur} == --* ]]; then
2020
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
2121

22-
case "$com" in
22+
case "${com}" in
2323
about)
2424
opts="${opts} "
2525
;;
@@ -109,18 +109,18 @@ function __composer_completion() {
109109

110110
# shellcheck disable=SC2207
111111
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
112-
__ltrim_colon_completions "$cur"
112+
__ltrim_colon_completions "${cur}"
113113

114114
return 0
115115
fi
116116

117117
# completing for a command
118-
if [[ "$cur" == "$com" ]]; then
118+
if [[ "${cur}" == "${com}" ]]; then
119119
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
120120

121121
# shellcheck disable=SC2207
122122
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
123-
__ltrim_colon_completions "$cur"
123+
__ltrim_colon_completions "${cur}"
124124

125125
return 0
126126
fi

completion/available/dart.completion.bash

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
22

33
__dart_completion() {
4+
# shellcheck disable=SC2155
45
local prev=$(_get_pword)
6+
# shellcheck disable=SC2155
57
local curr=$(_get_cword)
68

79
local HELP="--help -h"

completion/available/dmidecode.completion.bash

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
22

33
function __dmidecode_completion() {
4+
# shellcheck disable=SC2155
45
local prev=$(_get_pword)
6+
# shellcheck disable=SC2155
57
local curr=$(_get_cword)
68

79
case $prev in

completion/available/knife.completion.bash

+8-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ _KAC_is_file_newer_than() {
4242
_KAC_regen_cache() {
4343
local CACHE_NAME=$1
4444
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
45+
# shellcheck disable=SC2155
4546
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
4647
shift 1
4748
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
@@ -66,6 +67,7 @@ _KAC_get_command_from_cache_name() {
6667
# otherwise it waits for the cache to be generated
6768
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
6869
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
70+
# shellcheck disable=SC2155
6971
_KAC_get_and_regen_cache() {
7072
# the cache name can't have space in it
7173
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
@@ -100,7 +102,7 @@ _KAC_clean_cache() {
100102

101103
# perform a cache cleaning when loading this file
102104
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
103-
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
105+
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
104106

105107
#####################################
106108
### End of cache helper functions ###
@@ -118,7 +120,7 @@ _KAC_get_current_base_command() {
118120
local PREVIOUS="knife"
119121
local I=1
120122
local CURRENT
121-
while [ $I -le "$COMP_CWORD" ]; do
123+
while [[ "${I}" -le "${COMP_CWORD}" ]]; do
122124
# command words are all lower-case
123125
echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
124126
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
@@ -127,12 +129,13 @@ _KAC_get_current_base_command() {
127129
I=$((I + 1))
128130
done
129131
_KAC_CURRENT_COMMAND=$PREVIOUS
130-
[ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
132+
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
131133
}
132134

133135
# searches the position of the currently completed argument in the current base command
134136
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
135137
# assumes the current base command is complete
138+
# shellcheck disable=SC2155
136139
_KAC_get_current_arg_position() {
137140
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
138141
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
@@ -150,10 +153,11 @@ _KAC_get_current_arg_position() {
150153
_knife() {
151154
_KAC_get_and_regen_cache _KAC_knife_commands
152155
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
156+
# shellcheck disable=SC2034
153157
COMREPLY=()
154158
# get correct command & arg pos
155159
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
156-
RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq)
160+
RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)
157161

158162
# we need to process that raw list a bit, most notably for placeholders
159163
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)

completion/available/ngrok.completion.bash

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
22

33
__ngrok_completion() {
4+
# shellcheck disable=SC2155
45
local prev=$(_get_pword)
6+
# shellcheck disable=SC2155
57
local curr=$(_get_cword)
68

79
local BASE_NO_CONF="--log --log-format --log-level --help"

completion/available/notify-send.completion.bash

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
22

33
function __notify-send_completions() {
4+
# shellcheck disable=SC2155
45
local curr=$(_get_cword)
6+
# shellcheck disable=SC2155
57
local prev=$(_get_pword)
68

79
case $prev in

completion/available/sdkman.completion.bash

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
2-
_sdkman_complete() {
2+
3+
function _sdkman_complete() {
34
local CANDIDATES
45
local CANDIDATE_VERSIONS
6+
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
57

68
COMPREPLY=()
79

@@ -10,7 +12,7 @@ _sdkman_complete() {
1012
elif [ "$COMP_CWORD" -eq 2 ]; then
1113
case "${COMP_WORDS[COMP_CWORD - 1]}" in
1214
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
13-
CANDIDATES=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
15+
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
1416
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
1517
;;
1618
"env")
@@ -46,17 +48,17 @@ _sdkman_complete() {
4648
return 0
4749
}
4850

49-
_sdkman_candidate_local_versions() {
51+
function _sdkman_candidate_local_versions() {
5052

5153
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
5254

5355
}
5456

55-
_sdkman_candidate_all_versions() {
57+
function _sdkman_candidate_all_versions() {
5658

5759
candidate="$1"
5860
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
59-
if [ "$SDKMAN_OFFLINE_MODE" = "true" ]; then
61+
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
6062
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
6163
else
6264
# sdkman has a specific output format for Java candidate since
@@ -70,12 +72,12 @@ _sdkman_candidate_all_versions() {
7072
# "+" - local version
7173
# "*" - installed
7274
# ">" - currently in use
73-
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
75+
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
7476
fi
7577

7678
}
7779

78-
__sdkman_cleanup_local_versions() {
80+
function __sdkman_cleanup_local_versions() {
7981

8082
__sdkman_build_version_csv "$1" | tr ',' ' '
8183

completion/available/vuejs.completion.bash

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# shellcheck shell=bash
22

33
__vuejs_completion() {
4+
# shellcheck disable=SC2155
45
local prev=$(_get_pword)
6+
# shellcheck disable=SC2155
57
local curr=$(_get_cword)
68

79
case $prev in

hooks/dot-bash.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ for file in "$@"; do
1818
fi
1919
done
2020

21-
exit $exit_code
21+
exit "${exit_code:-0}"

hooks/dot-sh.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ for file in "$@"; do
1818
fi
1919
done
2020

21-
exit $exit_code
21+
exit "${exit_code:-0}"

install.sh

+14-14
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function _bash-it_check_for_backup() {
8383
fi
8484
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
8585

86-
if ! [[ $overwrite_backup ]]; then
87-
while ! [[ $silent ]]; do
86+
if [[ -z "${overwrite_backup}" ]]; then
87+
while [[ -z "${silent}" ]]; do
8888
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
8989
case $RESP in
9090
[yY])
@@ -100,9 +100,9 @@ function _bash-it_check_for_backup() {
100100
esac
101101
done
102102
fi
103-
if ! [[ $overwrite_backup ]]; then
103+
if [[ -z "${overwrite_backup}" ]]; then
104104
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
105-
if [[ $silent ]]; then
105+
if [[ -n "${silent}" ]]; then
106106
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
107107
fi
108108
exit 1
@@ -114,8 +114,8 @@ function _bash-it_check_for_backup() {
114114
function _bash-it_modify_config_files() {
115115
_bash-it_check_for_backup
116116

117-
if ! [[ $silent ]]; then
118-
while ! [[ $append_to_config ]]; do
117+
if [[ -z "${silent}" ]]; then
118+
while [[ -z "${append_to_config}" ]]; do
119119
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
120120
case $choice in
121121
[yY])
@@ -131,7 +131,7 @@ function _bash-it_modify_config_files() {
131131
esac
132132
done
133133
fi
134-
if [[ $append_to_config ]]; then
134+
if [[ -n "${append_to_config}" ]]; then
135135
# backup/append
136136
_bash-it_backup_append
137137
else
@@ -174,12 +174,12 @@ done
174174

175175
shift $((OPTIND - 1))
176176

177-
if [[ $silent ]] && [[ $interactive ]]; then
177+
if [[ -n "${silent}" && -n "${interactive}" ]]; then
178178
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
179179
exit 1
180180
fi
181181

182-
if [[ $no_modify_config ]] && [[ $append_to_config ]]; then
182+
if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
183183
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
184184
exit 1
185185
fi
@@ -197,7 +197,7 @@ esac
197197

198198
BACKUP_FILE=$CONFIG_FILE.bak
199199
echo "Installing bash-it"
200-
if ! [[ $no_modify_config ]]; then
200+
if [[ -z "${no_modify_config}" ]]; then
201201
_bash-it_modify_config_files
202202
fi
203203

@@ -212,10 +212,10 @@ cite _about _param _example _group _author _version
212212
# shellcheck source=./lib/helpers.bash
213213
source "$BASH_IT/lib/helpers.bash"
214214

215-
if [[ $interactive ]] && ! [[ $silent ]]; then
215+
if [[ -n $interactive && -z "${silent}" ]]; then
216216
for type in "aliases" "plugins" "completion"; do
217-
echo -e "\033[0;32mEnabling $type\033[0m"
218-
_bash-it_load_some $type
217+
echo -e "\033[0;32mEnabling ${type}\033[0m"
218+
_bash-it_load_some "$type"
219219
done
220220
else
221221
echo ""
@@ -230,7 +230,7 @@ fi
230230
echo ""
231231
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
232232
# shellcheck disable=SC2086
233-
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m"
233+
echo -e "\033[0;32mTo start using it, open a new tab or 'source "~/$CONFIG_FILE"'.\033[0m"
234234
echo ""
235235
echo "To show the available aliases/completions/plugins, type one of the following:"
236236
echo " bash-it show aliases"

lib/helpers.bash

100755100644
File mode changed.

lib/log.bash

100755100644
File mode changed.

lib/search.bash

100755100644
File mode changed.

lib/utilities.bash

100755100644
File mode changed.

0 commit comments

Comments
 (0)