Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove other_args declaration if it is no used #578

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

DannyBen
Copy link
Owner

@DannyBen DannyBen commented Dec 20, 2024

When inspect_args function is disbaled (e.g. when env = production), and there is no use for other_args (catch_all is not used), then shellcheck triggers a warning on this line:

run() {
  # ...
  declare -g -a other_args=()
  # ...
}

This PR:

  1. Adds a Command#catch_all_used_anywhere? method that checks if the command itself or any of its descendants is using catch_all
  2. Adds a condition check that uses this method before rendering the other_args declaration.

@DannyBen DannyBen added this to the 1.2.7 milestone Dec 20, 2024
@DannyBen DannyBen changed the title Fix shellcheck unused variable on other_args in production Remove other_args declaration if it is no used Dec 20, 2024
@DannyBen DannyBen merged commit 786d8db into master Dec 20, 2024
8 checks passed
@DannyBen DannyBen deleted the fix/other-args-shellcheck branch December 20, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant