Skip to content

Commit 808a8d4

Browse files
committed
Fix many shellcheck issues; ignore a few others
1 parent bf60c7f commit 808a8d4

26 files changed

Lines changed: 163 additions & 96 deletions

‎bin/asdf‎

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,114 @@
11
#!/usr/bin/env bash
22

3-
source $(dirname $(dirname $0))/lib/utils.sh
4-
5-
source $(dirname $(dirname $0))/lib/commands/help.sh
6-
source $(dirname $(dirname $0))/lib/commands/update.sh
7-
source $(dirname $(dirname $0))/lib/commands/install.sh
8-
source $(dirname $(dirname $0))/lib/commands/uninstall.sh
9-
source $(dirname $(dirname $0))/lib/commands/current.sh
10-
source $(dirname $(dirname $0))/lib/commands/where.sh
11-
source $(dirname $(dirname $0))/lib/commands/which.sh
12-
source $(dirname $(dirname $0))/lib/commands/version_commands.sh
13-
source $(dirname $(dirname $0))/lib/commands/list.sh
14-
source $(dirname $(dirname $0))/lib/commands/list-all.sh
15-
source $(dirname $(dirname $0))/lib/commands/reshim.sh
16-
source $(dirname $(dirname $0))/lib/commands/plugin-add.sh
17-
source $(dirname $(dirname $0))/lib/commands/plugin-list.sh
18-
source $(dirname $(dirname $0))/lib/commands/plugin-list-all.sh
19-
source $(dirname $(dirname $0))/lib/commands/plugin-update.sh
20-
source $(dirname $(dirname $0))/lib/commands/plugin-remove.sh
21-
22-
source $(dirname $(dirname $0))/lib/commands/plugin-push.sh
23-
source $(dirname $(dirname $0))/lib/commands/plugin-test.sh
24-
25-
3+
# shellcheck source=lib/utils.sh
4+
source "$(dirname "$(dirname "$0")")/lib/utils.sh"
5+
6+
# shellcheck source=lib/commands/help.sh
7+
source "$(dirname "$(dirname "$0")")/lib/commands/help.sh"
8+
# shellcheck source=lib/commands/update.sh
9+
source "$(dirname "$(dirname "$0")")/lib/commands/update.sh"
10+
# shellcheck source=lib/commands/install.sh
11+
source "$(dirname "$(dirname "$0")")/lib/commands/install.sh"
12+
# shellcheck source=lib/commands/uninstall.sh
13+
source "$(dirname "$(dirname "$0")")/lib/commands/uninstall.sh"
14+
# shellcheck source=lib/commands/current.sh
15+
source "$(dirname "$(dirname "$0")")/lib/commands/current.sh"
16+
# shellcheck source=lib/commands/where.sh
17+
source "$(dirname "$(dirname "$0")")/lib/commands/where.sh"
18+
# shellcheck source=lib/commands/which.sh
19+
source "$(dirname "$(dirname "$0")")/lib/commands/which.sh"
20+
# shellcheck source=lib/commands/version_commands.sh
21+
source "$(dirname "$(dirname "$0")")/lib/commands/version_commands.sh"
22+
# shellcheck source=lib/commands/list.sh
23+
source "$(dirname "$(dirname "$0")")/lib/commands/list.sh"
24+
# shellcheck source=lib/commands/list-all.sh
25+
source "$(dirname "$(dirname "$0")")/lib/commands/list-all.sh"
26+
# shellcheck source=lib/commands/reshim.sh
27+
source "$(dirname "$(dirname "$0")")/lib/commands/reshim.sh"
28+
# shellcheck source=lib/commands/plugin-add.sh
29+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-add.sh"
30+
# shellcheck source=lib/commands/plugin-list.sh
31+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-list.sh"
32+
# shellcheck source=lib/commands/plugin-list-all.sh
33+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-list-all.sh"
34+
# shellcheck source=lib/commands/plugin-update.sh
35+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-update.sh"
36+
# shellcheck source=lib/commands/plugin-remove.sh
37+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-remove.sh"
38+
39+
# shellcheck source=lib/commands/plugin-push.sh
40+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-push.sh"
41+
# shellcheck source=lib/commands/plugin-test.sh
42+
source "$(dirname "$(dirname "$0")")/lib/commands/plugin-test.sh"
43+
44+
# shellcheck disable=SC2124
2645
callback_args="${@:2}"
2746

2847
case $1 in
2948

3049
"--version")
31-
asdf_version $callback_args;;
50+
asdf_version "$callback_args";;
3251

3352
"help")
34-
help_command $callback_args;;
53+
help_command "$callback_args";;
3554

3655
"update")
37-
update_command $callback_args;;
56+
update_command "$callback_args";;
3857

3958
"install")
40-
install_command $callback_args;;
59+
install_command "$callback_args";;
4160

4261
"uninstall")
43-
uninstall_command $callback_args;;
62+
uninstall_command "$callback_args";;
4463

4564
"current")
46-
current_command $callback_args;;
65+
current_command "$callback_args";;
4766

4867
"where")
49-
where_command $callback_args;;
68+
where_command "$callback_args";;
5069

5170
"which")
52-
which_command $callback_args;;
71+
which_command "$callback_args";;
5372

5473
"local")
55-
local_command $callback_args;;
74+
local_command "$callback_args";;
5675

5776
"global")
58-
global_command $callback_args;;
77+
global_command "$callback_args";;
5978

6079
"list")
61-
list_command $callback_args;;
80+
list_command "$callback_args";;
6281

6382
"list-all")
64-
list_all_command $callback_args;;
83+
list_all_command "$callback_args";;
6584

6685
"shim")
67-
shim_command $callback_args;;
86+
shim_command "$callback_args";;
6887

6988
"reshim")
70-
reshim_command $callback_args;;
89+
reshim_command "$callback_args";;
7190

7291
"plugin-add")
73-
plugin_add_command $callback_args;;
92+
plugin_add_command "$callback_args";;
7493

7594
"plugin-list")
76-
plugin_list_command $callback_args;;
95+
plugin_list_command "$callback_args";;
7796

7897
"plugin-list-all")
79-
plugin_list_all_command $callback_args;;
98+
plugin_list_all_command "$callback_args";;
8099

81100
"plugin-update")
82-
plugin_update_command $callback_args;;
101+
plugin_update_command "$callback_args";;
83102

84103
"plugin-remove")
85-
plugin_remove_command $callback_args;;
104+
plugin_remove_command "$callback_args";;
86105

87106
# Undocumented commands for development
88107
"plugin-push")
89-
plugin_push_command $callback_args;;
108+
plugin_push_command "$callback_args";;
90109

91110
"plugin-test")
92-
plugin_test_command $callback_args;;
111+
plugin_test_command "$callback_args";;
93112

94113
*)
95114
help_command

‎bin/private/asdf-exec‎

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
#!/usr/bin/env bash
22

3-
source $(dirname $(dirname $(dirname $0)))/lib/utils.sh
3+
# shellcheck source=lib/utils.sh
4+
source "$(dirname "$(dirname "$(dirname "$0")")")/lib/utils.sh"
45

56
plugin_name=$1
67
executable_path=$2
78

8-
plugin_path=$(get_plugin_path $plugin_name)
9-
check_if_plugin_exists $plugin_name
9+
plugin_path=$(get_plugin_path "$plugin_name")
10+
check_if_plugin_exists "$plugin_name"
1011

11-
full_version=$(get_preset_version_for $plugin_name)
12+
full_version=$(get_preset_version_for "$plugin_name")
1213

1314
if [ "$full_version" == "" ]; then
1415
echo "No version set for ${plugin_name}"
1516
exit -1
1617
fi
1718

19+
# shellcheck disable=SC2162
1820
IFS=' ' read -a versions <<< "$full_version"
1921

2022
for version in "${versions[@]}"; do
21-
install_path=$(find_install_path $plugin_name $version)
23+
install_path=$(find_install_path "$plugin_name" "$version")
2224

23-
if [ $version != "system" ] && [ ! -d "$install_path" ]; then
25+
if [ "$version" != "system" ] && [ ! -d "$install_path" ]; then
2426
echo "$plugin_name $version not installed"
2527
exit 1
2628
fi
2729

28-
full_executable_path=$(get_executable_path $plugin_name $version $executable_path)
30+
if full_executable_path=$(get_executable_path "$plugin_name" "$version" "$executable_path"); then
31+
if [ -f "$full_executable_path" ]; then
32+
if [ -f "${plugin_path}/bin/exec-env" ]; then
33+
export ASDF_INSTALL_TYPE=$install_type
34+
export ASDF_INSTALL_VERSION=$version
35+
export ASDF_INSTALL_PATH=$install_path
2936

30-
if [ $? -eq 0 -a -f "$full_executable_path" ]; then
31-
if [ -f ${plugin_path}/bin/exec-env ]; then
32-
export ASDF_INSTALL_TYPE=$install_type
33-
export ASDF_INSTALL_VERSION=$version
34-
export ASDF_INSTALL_PATH=$install_path
37+
source "${plugin_path}/bin/exec-env"
3538

36-
source ${plugin_path}/bin/exec-env
39+
# unset everything, we don't want to pollute
40+
unset ASDF_INSTALL_TYPE
41+
unset ASDF_INSTALL_VERSION
42+
unset ASDF_INSTALL_PATH
43+
fi
3744

38-
# unset everything, we don't want to pollute
39-
unset ASDF_INSTALL_TYPE
40-
unset ASDF_INSTALL_VERSION
41-
unset ASDF_INSTALL_PATH
45+
exec "$full_executable_path" "${@:3}"
4246
fi
43-
44-
exec $full_executable_path "${@:3}"
4547
fi
4648
done
4749

‎completions/asdf.bash‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
#!/usr/bin/env bash
22

33
_asdf () {
4-
local cur=${COMP_WORDS[COMP_CWORD]}
5-
local cmd=${COMP_WORDS[1]}
6-
local prev=${COMP_WORDS[COMP_CWORD-1]}
7-
local plugins=$(asdf plugin-list | tr '\n' ' ')
4+
local cur
5+
cur=${COMP_WORDS[COMP_CWORD]}
6+
local cmd
7+
cmd=${COMP_WORDS[1]}
8+
local prev
9+
prev=${COMP_WORDS[COMP_CWORD-1]}
10+
local plugins
11+
plugins=$(asdf plugin-list | tr '\n' ' ')
812

913
COMPREPLY=()
1014

1115
case "$cmd" in
1216
plugin-update)
13-
COMPREPLY=($(compgen -W "$plugins --all" -- $cur))
17+
COMPREPLY=($(compgen -W "$plugins --all" -- "$cur"))
1418
;;
1519
plugin-remove|current|list|list-all)
16-
COMPREPLY=($(compgen -W "$plugins" -- $cur))
20+
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
1721
;;
1822
install)
1923
if [[ "$plugins" == *"$prev"* ]] ; then
20-
local versions=$(asdf list-all $prev)
21-
COMPREPLY=($(compgen -W "$versions" -- $cur))
24+
local versions
25+
versions=$(asdf list-all "$prev")
26+
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
2227
else
23-
COMPREPLY=($(compgen -W "$plugins" -- $cur))
28+
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
2429
fi
2530
;;
2631
uninstall|where|reshim|local|global)
2732
if [[ "$plugins" == *"$prev"* ]] ; then
28-
local versions=$(asdf list $prev)
29-
COMPREPLY=($(compgen -W "$versions" -- $cur))
33+
local versions
34+
versions=$(asdf list "$prev")
35+
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
3036
else
31-
COMPREPLY=($(compgen -W "$plugins" -- $cur))
37+
COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
3238
fi
3339
;;
3440
*)
3541
local cmds='plugin-add plugin-list plugin-remove plugin-update install uninstall update current where which list list-all local global reshim'
36-
COMPREPLY=($(compgen -W "$cmds" -- $cur))
42+
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
3743
;;
3844
esac
3945

‎lib/commands/current.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
plugin_current_command() {
24
local plugin_name=$1
35

‎lib/commands/help.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
help_command () {
24
echo "version: $(asdf_version)"
35
echo ""

‎lib/commands/install.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
handle_failure() {
24
local install_path="$1"
35
rm -rf "$install_path"

‎lib/commands/list-all.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
list_all_command() {
24
local plugin_name=$1
35
local plugin_path=$(get_plugin_path $plugin_name)

‎lib/commands/list.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
list_command() {
24
local plugin_name=$1
35
check_if_plugin_exists $plugin_name

‎lib/commands/plugin-add.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
plugin_add_command() {
24
if [[ $# -lt 1 || $# -gt 2 ]]; then
35
display_error "usage: asdf plugin-add <name> [<git-url>]"

‎lib/commands/plugin-list.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
13
plugin_list_command() {
24
local plugins_path=$(get_plugin_path)
35

0 commit comments

Comments
 (0)