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

🐛 Colors are broken on zsh: cross-platform #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcellodesales
Copy link

@marcellodesales marcellodesales commented Feb 9, 2021

According to https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux?rq=1#comment24883926_5947802, the format can be incorrect in some terminals with \e. Replacing it with \033 should be cross-terminal compatible.

The following is the output in a MacOS with ZSh:

$ bash logger.sh
\e[41;37m[2021-02-08             15:40:33.N             ][FATAL ][main:18 ] fatal level\e[0m
\e[1;31m[2021-02-08             15:40:33.N             ][ERROR ][main:19 ] error level\e[0m
\e[1;33m[2021-02-08             15:40:33.N             ][WARN  ][main:20 ] warning level\e[0m
\e[1;32m[2021-02-08             15:40:33.N             ][NOTICE][main:21 ] notice level\e[0m
\e[37m[2021-02-08             15:40:33.N             ][INFO  ][main:22 ] info level\e[0m
\e[1;34m[2021-02-08             15:40:33.N             ][DEBUG ][main:23 ] debug level\e[0m
\e[94m[2021-02-08             15:40:33.N             ][TRACE ][main:24 ] trace level\e[0m

Fix

  • After replacing \e with \033

Screen Shot 2021-02-08 at 4 00 05 PM

According to https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux?rq=1#comment24883926_5947802, the format can be incorrect in some terminals with `\e`. Replacing it with `\033` should be cross-terminal compatible
@marcellodesales
Copy link
Author

NOTE

  • This is if you use sh to start your script

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.

1 participant