Skip to content

fix(shell): double quote params - #824

Merged
typicode merged 4 commits into
typicode:nextfrom
dargmuesli:symlink
Jan 27, 2021
Merged

typicode merged 4 commits into
typicode:nextfrom
dargmuesli:symlink

Conversation

@dargmuesli

Copy link
Copy Markdown
Contributor

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

@typicode

typicode commented Dec 7, 2020

Copy link
Copy Markdown
Owner

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

@dargmuesli

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Why is the CI failing btw? :0

@dargmuesli

Copy link
Copy Markdown
Contributor Author

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

@typicode

Copy link
Copy Markdown
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" 👍

Comment thread .husky/commit-msg
Comment thread scripts/pre-commit
Comment thread src/commands/add.ts Outdated
}

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

Copy link
Copy Markdown
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
Copy Markdown
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 (?) :)

Comment thread test/sub-dir.sh
@@ -1,4 +1,4 @@
. $(dirname $0)/_functions.sh
. $(dirname "$0")/_functions.sh

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@typicode typicode left a comment •

Copy link
Copy Markdown
Owner

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
zeekay pushed a commit to hanzoai/husky that referenced this pull request Sep 9, 2026
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.

2 participants