qmake“系统"命令有时返回空字符串而不是实际响应 [英] qmake "system" command sometime returns empty string rather than the real response

查看:98
本文介绍了qmake“系统"命令有时返回空字符串而不是实际响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Qt Creator解释的脚本中经常使用或可能滥用qmake的系统"命令.例如,命令

I use, or perhaps abuse, the "system" command of qmake a lot in scripts interpreted by Qt Creator. As an example the command

RESPONSE = $$system(ls)

在OSX中将使用工作目录的内容填充字符串列表RESPONSE.之后,可以在qmake中使用RESPONSE进行很多字符串操作.

will in OSX populate the stringlist RESPONSE with the content of the working dir. After that a lot of string manipulation with RESPONSE can be done inside qmake.

但是我注意到,使用诸如"codesign"之类的Xcode实用程序,存在系统响应(如Qt Creator中的"Compile Window"中所示),但是该响应未放入RESPONSE中.

However I noticed that with the Xcode utilities like "codesign" there is a system response (as shown in the "Compile Window" in Qt Creator) but the response is not put in RESPONSE.

有没有办法掌握qmake中诸如codesign之类的实用程序的响应?

Is there a way to get to get hold of the response of utilities like codesign inside qmake?

推荐答案

这些实用程序输出到stderr,而不是stdout.您需要在将stderr重定向到stdout的外壳程序包装中运行它们,例如bash -c 'codesign ... 2>&1'

These utilities output to stderr, not stdout. You'll need to run them in a shell wrapper that redirects stderr to stdout, like bash -c 'codesign ... 2>&1'

这篇关于qmake“系统"命令有时返回空字符串而不是实际响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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