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

HUSKY: unbound variable #1358

Closed
sdavids opened this issue Jan 25, 2024 · 4 comments · Fixed by #1359
Closed

HUSKY: unbound variable #1358

sdavids opened this issue Jan 25, 2024 · 4 comments · Fixed by #1359

Comments

@sdavids
Copy link

sdavids commented Jan 25, 2024

.husky/_/h: line 13: HUSKY: unbound variable

Context

~/.config/husky/init.sh

#!/usr/bin/env sh
set -eu

[ -e /etc/zshenv ] && . /etc/zshenv
[ -e "${ZDOTDIR:=${HOME}}/.zshenv" ] && . "${ZDOTDIR:=${HOME}}/.zshenv"
[ -e /etc/zprofile ] && . /etc/zprofile
[ -e "${ZDOTDIR:=${HOME}}/.zprofile" ] && . "${ZDOTDIR:=${HOME}}/.zprofile"
[ -e /etc/zlogin ] && . /etc/zlogin
[ -e "${ZDOTDIR:=${HOME}}/.zlogin" ] && . "${ZDOTDIR:=${HOME}}/.zlogin"

Possible Solution

Use

${HUSKY:-}

instead of

$HUSKY

in the h script.

Background Info

https://stackoverflow.com/a/44606194

@typicode
Copy link
Owner

typicode commented Jan 25, 2024

Thank you for the report and solution. PR ready.

@glensc
Copy link
Contributor

glensc commented Jan 29, 2024

no. the pr didn't fix anything:

@typicode
Copy link
Owner

Since HUSKY env variable is moved before set -u and H is declared, there should be no error or am I missing something?

@glensc
Copy link
Contributor

glensc commented Jan 30, 2024

Ahaa, I did not look at that angle. So yes.

The only way to have -u is to do it externally from the script: sh -u husky.sh which does not need to be supported.

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 a pull request may close this issue.

3 participants