Skip to content

feat: add shellcheck ci check#1179

Merged
hyperupcall merged 4 commits intotj:mainfrom
oikarinen:shellcheck
Dec 21, 2024
Merged

feat: add shellcheck ci check#1179
hyperupcall merged 4 commits intotj:mainfrom
oikarinen:shellcheck

Conversation

@oikarinen
Copy link
Copy Markdown
Contributor

This was mentioned in some older PR. Autofixes in the same commit, some which seem actual bugs.

Comment thread bin/git-obliterate Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

range may contain multiple options, let's add a shellcheck disable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert here but converted range to array so that multiple values would be quoted correctly in (theoretical) case they'd contain IFS or glob characters. LMKWYT? Could also just shellcheck disable=SC2086. Thanks for quick feedback on these few items 😎

@spacewander
Copy link
Copy Markdown
Collaborator

Let's merge main branch to make CI pass.

Comment thread bin/git-obliterate Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "${range[*]}"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what SC2086 doc indicated and looks correct based on the bash docs.

If the subscript is ‘@’ or ‘’, the word expands to all members of the array name. These subscripts differ only when the word appears within double quotes. If the word is double-quoted, ${name[]} expands to a single word with the value of each array member separated by the first character of the IFS variable, and ${name[@]} expands each element of name to a separate word.

And indeed that seems to be the case:

$ ranges=( "range 1" "range 2" "range 3" ); for range in "${ranges[*]}"; do echo "$range"; done
range 1 range 2 range 3
$ ranges=( "range 1" "range 2" "range 3" ); for range in "${ranges[@]}"; do echo "$range"; done
range 1
range 2
range 3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@spacewander
Copy link
Copy Markdown
Collaborator

@oikarinen
Would you solve #1180 (comment)?

@hyperupcall
Copy link
Copy Markdown
Collaborator

Thanks for adding this! This finishes up the rest of the ShellCheck improvements that I originally made in #1075 and #1056

Copy link
Copy Markdown
Collaborator

@hyperupcall hyperupcall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted a few issues with the new changes. Could you go back and test any of the non-trivial changes to make sure they work?

Comment thread bin/git-guilt Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new changes will cause git blame to fail whenever -w (or --ignore-whitespace) is not supplied at the command line.

Comment thread bin/git-scp Outdated
Copy link
Copy Markdown
Collaborator

@hyperupcall hyperupcall Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new changes will now cause git add to fail in all cases (except the case where a single file is in list). Before, it would only fail on files that contained whitespace.

Comment thread bin/git-scp Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as below.

@oikarinen
Copy link
Copy Markdown
Contributor Author

I spotted a few issues with the new changes. Could you go back and test any of the non-trivial changes to make sure they work?

Thanks, if the test suite doesn't cover the changes probably best approach is to just ignore and perhaps have an issue(s) in backlog to fix those to limit the size of the PR.

@hyperupcall
Copy link
Copy Markdown
Collaborator

Thanks, if the test suite doesn't cover the changes probably best approach is to just ignore and perhaps have an issue(s) in backlog to fix those to limit the size of the PR.

Sounds good to me!

Comment thread bin/git-scp Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indent and bad location?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, tabs vs spaces thing. Sorry I rebased the branch to main instead of merge from old habits :(

@hyperupcall
Copy link
Copy Markdown
Collaborator

Great, thanks!

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.

3 participants