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

fix(shell): double quote params #824

Merged
merged 4 commits into from Jan 27, 2021
Merged

fix(shell): double quote params #824

merged 4 commits into from Jan 27, 2021

Conversation

dargmuesli
Copy link
Contributor

I've set test/default.sh's shebang to bash because echo -e is used in this file.

@typicode
Copy link
Owner

typicode commented Dec 7, 2020

Thanks for the PR.
What would be the use case for symlinked hooks?

@dargmuesli
Copy link
Contributor Author

Any application that parses the git hooks directory itself without respecting a custom directory set through git config, like GitKraken for example. I suggested respecting the config setting to them earlier today, but until then the many users of GitKraken won't see husky v5 hooks executed as long as they don't add symlinks to the default git hook directory.

@dargmuesli
Copy link
Contributor Author

Why is the CI failing btw? :0

@dargmuesli
Copy link
Contributor Author

I resolved the merge conflicts. @typicode what's your status on this PR? :)

@typicode
Copy link
Owner

Hmm, I'd prefer to keep the script as it is and not rely on readlink. I'd rather not have fixes for external tools in husky.

However, if users want to edit their pre-commit hook to handle specifically some tools, they can edit this line manually.

As for the rest LGTM, good catch on the "$0" 👍

.husky/commit-msg Show resolved Hide resolved
scripts/pre-commit Show resolved Hide resolved
@@ -15,7 +15,12 @@ function createHookFile(file: string, cmd: string) {
throw new Error(`${file} already exists`)
}

const data = ['#!/bin/sh', '. "$(dirname $0)/_/husky.sh"', '', cmd].join('\n')
const data = [
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const data = [
const data = ['#!/bin/sh', '. "$(dirname "$0")/_/husky.sh"', '', cmd].join('\n')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, except for the additional indentation (?) :)

@@ -1,4 +1,4 @@
. $(dirname $0)/_functions.sh
. $(dirname "$0")/_functions.sh
Copy link
Owner

Choose a reason for hiding this comment

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

👍 could you change test/config-dir.sh too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

test/default.sh Outdated
@@ -1,4 +1,7 @@
. $(dirname $0)/_functions.sh
#!/bin/bash
Copy link
Owner

Choose a reason for hiding this comment

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

I think the shebang can be removed since these scripts are not executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced that with the shellcheck comment.

@dargmuesli
Copy link
Contributor Author

I'd rather not have fixes for external tools in husky.

I don't really see it as a fix for external tools but as broadened functionality for husky even if the "fix" happened to be the reason for this PR.

Copy link
Owner

@typicode typicode left a comment

Choose a reason for hiding this comment

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

Thanks! :)

This was referenced Mar 15, 2021
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

2 participants