typicode / husky

Git hooks made easy 🐶 woof!
https://typicode.github.io/husky
MIT License
31.68k stars 996 forks source link

[HELP] pre-commit and echo -e #1388

Closed eleftrik closed 3 months ago

eleftrik commented 3 months ago

This is not an issue.

In my pre-commit hook I got several lines like this:

echo -e "And occurred.\n\nPlease check etc."

The problem is that -e is printed on the screen, but it shouldn't. (Sorry, maybe I'm lacking some Bash concepts).

I use a custom directory for GIT hooks: .git/config has hooksPath = .encodia/dev/githooks/_.

I was able to fix the problem removing the final underscore (so .git/config has hooksPath = .encodia/dev/githooks). This way, -e is not shown anymore on the screen (problem solved), but npm prepare every time adds /_ again to .git/config.

What am I doing wrong? I guess the _ is required because it runs some internal scripts. To summarize, I would like to be able to run echo -e "...." without problems. Any hint?

Thank you!

yuyutar1 commented 3 months ago

@eleftrik Could it be an environmental dependency issue?

Using "printf" rather than "echo -e" may give the expected behavior.

eleftrik commented 3 months ago

@yuyutar1 Honestly, I don't know... 🤷 I never noticed this problem. I've always used echo -e in my scripts and got the expected behavior. I started to experience this "issue" after upgrading Husky to the latest release. I think I could use printf, but I solved it by removing -e from echo lines. I just wanted to understand what's happening for the sake of curiosity 😄

eleftrik commented 3 months ago

Oh, I think I got it.

_/h script (which is included by Husky) starts with

#!/usr/bin/env sh

So, I think Korn shell doesn't support -e.