Reputation: 1011
I recently switched to a Macbook Air and thus to OS X. I imported some of my current projects to it and tried to compile them with my Makefile.
My Makefile has some custom imput adding colors with /bin/echo -e "\033[0;31m" for example + the text. It's working great on my old computer (OpenSuse distrib) but it doesn't even compile my binary anymore on my Mac. Here's what I get when I try to prompt a custom line through my Makefile :
-e \033[0;31m (MY TEXT) \033[00m
As I use custom imput when compiling my .o files, none of them are get compiled so my project build fail. My Makefile work great without these custom output but I'd like to know why they don't work on OS X.
I can post my Makefile code if some people request it for further investigation.
Upvotes: 1
Views: 679
Reputation: 54583
This is similar, but not quite a duplicate of Color termcaps Konsole?. The problem is that -e
is not an option of OSX echo (which follows POSIX). If you take out the -e
, it will work as you expect.
The -e
option is used in some implementations to allow \e
as a synonym for \033
(but your example uses the latter anyway).
Whether you use echo
or printf
for POSIX scripts is largely a matter of taste, since both accept the same set of backslash sequences. For example printf
, of course, accepts %
sequences for formatting numbers, but C++ programmers have gotten into the habit of (cout vs echo) not using the printf
-style calls.
For reference.
Upvotes: 2