Skip to content

Commit 786d8db

Browse files
authored
Merge pull request #578 from DannyBen/fix/other-args-shellcheck
Remove `other_args` declaration if it is no used
2 parents 16568b7 + 82fe069 commit 786d8db

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

lib/bashly/script/introspection/commands.rb

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ module Bashly
22
module Script
33
module Introspection
44
module Commands
5+
# Returns true if the command or any of its descendants has `catch_all`
6+
def catch_all_used_anywhere?
7+
deep_commands(include_self: true).any? { |x| x.catch_all.enabled? }
8+
end
9+
510
# Returns a full list of the Command names and aliases combined
611
def command_aliases
712
commands.map(&:aliases).flatten

lib/bashly/views/command/inspect_args.gtx

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
> echo args: none
1212
> fi
1313
>
14+
15+
if catch_all_used_anywhere?
1416
> if ((${#other_args[@]})); then
1517
> echo
1618
> echo other_args:
@@ -20,6 +22,8 @@
2022
> done
2123
> fi
2224
>
25+
end
26+
2327
if Settings.enabled? :deps_array
2428
> if ((${#deps[@]})); then
2529
> readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
@@ -31,6 +35,7 @@ if Settings.enabled? :deps_array
3135
> fi
3236
>
3337
end
38+
3439
if Settings.enabled? :env_var_names_array
3540
> if ((${#env_var_names[@]})); then
3641
> readarray -t sorted_names < <(printf '%s\n' "${env_var_names[@]}" | sort)

lib/bashly/views/command/run.gtx

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@
22

33
> run() {
44
> declare -g -A args=()
5+
6+
if catch_all_used_anywhere?
7+
> declare -g -a other_args=()
8+
end
9+
510
if Settings.enabled? :deps_array
611
> declare -g -A deps=()
712
end
8-
> declare -g -a other_args=()
13+
914
if Settings.enabled? :env_var_names_array
1015
> declare -g -a env_var_names=()
1116
end
17+
1218
> declare -g -a input=()
19+
1320
if has_unique_args_or_flags?
1421
> declare -g -A unique_lookup=()
1522
end
23+
1624
> normalize_input "$@"
1725
> parse_requirements "${input[@]}"
26+
1827
if user_file_exist?('before')
1928
> before_hook
2029
end
30+
2131
>
2232
> case "$action" in
23-
2433
deep_commands.each do |command|
2534
> "{{ command.action_name }}") {{ command.function_name }}_command ;;
2635
end

0 commit comments

Comments
 (0)