carloscuesta / gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻
https://www.npmjs.com/package/gitmoji-cli
MIT License
4.64k stars 206 forks source link

gitmoji-cli 3.2.2 showing weird messages in terminal when commiting #330

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello @carloscuesta!

Hi, I updated to 3.2.2, and everything seems to work fine, except some weird messages appearing in my terminal when commiting

Anyways, this isn't important. I can commit changes, but I think this should be fixed

This is my terminal log:

andres on acer laptop at Alexis > git commit events/client/message.js 
// These are the error messages
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
.git/hooks/prepare-commit-msg: 6: [[: not found
.git/hooks/prepare-commit-msg: 8: [[: not found
// Now, the usual behavior continues.
? Choose a gitmoji: 🔥  - Removing code or files.
? Enter the commit title [23/48]: Removed betacmd feature
? Enter the commit message: Removed betacmd feature in message.js. Separate beta
 bot will be created
[master 334b70b] 🔥 Removed betacmd feature
 1 file changed, 31 deletions(-)

OS: Ubuntu 19.10 gitmoji-cli -v: 3.2.2 Node version: 12.16.1

Error Message: None

carloscuesta commented 4 years ago

Looks like a syntax issue on the hook 😅. Can't reproduce it on an OS X machine

carloscuesta commented 4 years ago

I'm going to revert the changes we made into the hook, since it's a delicate thing to change

Fixed at 3.2.3

carloscuesta commented 4 years ago

https://github.com/carloscuesta/gitmoji-cli/commit/c668e779d4866188c7fe8a3b7be8d56309e065d0

ghost commented 4 years ago

Now working! Thank you!

Addono commented 4 years ago

Hmm, my bad 😞 The changes I made to the hook script were using some extensions to the POSIX shell, which are only supported in shells like bash and zsh. It is not reproducible on MacOS as MacOS defaults to using a shell with extended POSIX support.

https://github.com/carloscuesta/gitmoji-cli/blob/8f71bff1561b180cd25c8bb734c77adf154d8bf7/src/commands/hook/hook.js#L5 This shebang should be replaced with #!/bin/bash or #!/usr/bin/env bash instead.

I'd add that if your script doesn't start with a shebang that explicitly requests a shell that supports [[ ]] (e.g. bash with #!/bin/bash or #!/usr/bin/env bash), you should use the portable option. Scripts that assume /bin/sh supports extensions like this will break on OSes like recent Debian and Ubuntu releases where that's not the case. – Gordon Davisson https://stackoverflow.com/a/13542854/7500339