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
Convert 'echo' to 'echo -e' to enable color escape codes #44
Conversation
Not sure how this wasn't noticed before now, but I suppose it's possible that some shells come with a version of 'echo' where the '-e' flag is considered active by default. However, on my system (CentOS 6.0, bash 4.1.2) doing any sort of command that echoes color codes prints garbage like the following: [user@machine ~]$ n \033[32mο\033[0m 0.6.5 \033[90m\033[0m All this commit does is add the '-e' flag to only those 'echo' commands that are using color escape codes. This causes the above command to print its output as expected. I'm not sure if this will break anything on shells that assume '-e' implicitly. For reference, here is the section of the 'echo' man page regarding '-e': -e enable interpretation of backslash escapes If -e is in effect, the following sequences are recognized: \\ backslash \a alert (BEL) \b backspace \c produce no further output \e escape \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \0NNN byte with octal value NNN (1 to 3 digits) \xHH byte with hexadecimal value HH (1 to 2 digits)
...Of course, why would I ever bother looking at the issues to check to see if someone's already submitted a fix :P In any case, is it confirmed that adding -e to the echo calls even breaks anything? I've seen other projects that don't bother special-casing their echoes. If this isn't the case, then adding an option for color as per #18 seems like overkill. |
I get:
|
I see. :( Out of curiosity, what's your setup? |
osx bash 3.2.48 |
upgraded to 4.2.x, same deal |
Here, try this command instead of echo:
If this works for you, then I think we can assume that printf can be swapped in for echo. |
i'll give it a try, i've had less interoperability issues with printf (oddly), bit of a piss-off that such as simple command like echo is varied haha |
seems fine for me |
getting
with replacing |
damnit haha, i dont get why everyone ditches |
Might I suggest following the example given here by including this at the top of the script:
Supposedly
|
On my machine, using this tool looks like the following:
To make the color escape codes work properly, just had to add the '-e' flag to the echoes that use them.