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

plugins: Fix shellcheck warnings on already linted files #1936

Merged
merged 1 commit into from
Sep 12, 2021

Conversation

NoahGorny
Copy link
Member

For some reason, running lint_clean_files.sh locally resulted in some errors for me, although it is ran on every PR...

Description

Fix small shellcheck quoting warnings

Motivation and Context

Clears up lint_clean_files.sh to not error out

How Has This Been Tested?

lint ran, tests as well

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@@ -309,7 +309,7 @@ function git-changelog() {
# shellcheck disable=SC2162
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
echo
echo [$DATE]
echo ["$DATE"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the brackets should be inside the quotes

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not really matter, but it does look nicer when the brackets are inside, changed

Copy link
Contributor

@gaelicWizard gaelicWizard Sep 9, 2021

Choose a reason for hiding this comment

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

Behavior is subtly different in some ways, consider:

cd /tmp
touch "a"
touch "b"
echo ["ab"]

The intent is clearly the characters ab printed, but the result is a b because the [/] is making it a pattern to be globbed and it's matching on the files in the directory.

Then, try this:

cd /tmp
touch "a"
rm -f "b"
echo ["ab"]

Again, the intent would be to see ab, but the result is just a because the globbing matching the pattern but only partially.

My rule of thumb is: if you want that thing, then quote it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, you are very correct!

@NoahGorny NoahGorny merged commit 99eab7a into Bash-it:master Sep 12, 2021
@NoahGorny NoahGorny deleted the fix-shellcheck-warnings branch September 12, 2021 05:13
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.

None yet

3 participants