[Makefile]添加颜色在 OS X 上不起作用 [英] [Makefile]Adding colors doesn't work on OS X

查看:91
本文介绍了[Makefile]添加颜色在 OS X 上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近改用Macbook Air,因此改用OSX.我向其中导入了一些当前项目,并尝试使用Makefile对其进行编译.

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.

我的Makefile具有一些自定义的归因输入,例如/bin/echo -e"\ 033 [0; 31m" +文本.在我的旧计算机(OpenSuse distrib)上,它运行良好,但在Mac上甚至无法编译我的二进制文件.这是当我尝试通过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

由于我在编译.o文件时使用自定义输入,因此没有一个文件被编译,因此我的项目构建失败.我的 Makefile 在没有这些自定义输出的情况下运行良好,但我想知道为什么它们不能在 OS X 上运行.

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.

如果有人要求进行进一步调查,我可以发布我的Makefile代码.

I can post my Makefile code if some people request it for further investigation.

推荐答案

这与 POSIX ).如果取出 -e ,它将按预期工作.

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.

在某些实现中,使用 -e 选项允许 \ e 作为 \ 033 的同义词(但是您的示例使用了后者)无论如何).

The -e option is used in some implementations to allow \e as a synonym for \033 (but your example uses the latter anyway).

对于POSIX脚本,是否使用 echo printf 在很大程度上取决于个人喜好,因为两者都接受相同的反斜杠序列集.例如, printf 当然接受序列来格式化数字,但是C ++程序员已经习惯了(cout vs echo)不使用 printf 样式的调用.

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.

供参考.

这篇关于[Makefile]添加颜色在 OS X 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆