Skip to content

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.

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 force-pushed the fix-shellcheck-warnings branch from a334469 to c6f6d8c Compare September 9, 2021 17:57
@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.

3 participants