变量 – Makefile和$$的使用
发布时间:2020-12-16 03:42:26 所属栏目:百科 来源:网络整理
导读:所以我有一个Makefile,其中我有以下代码,我试图理解: for file_exe in `find . -name "zip_exe-*"`; do ./$${file_exe} -d $(UNZIP_PATH)/lib; done 据我所知,这段代码将尝试找到一些可执行的zip并将这些zip文件解压缩到一个位置.但令我困惑的是$${file_
所以我有一个Makefile,其中我有以下代码,我试图理解:
for file_exe in `find . -name "zip_exe-*"`; do ./$${file_exe} -d $(UNZIP_PATH)/lib; done 据我所知,这段代码将尝试找到一些可执行的zip并将这些zip文件解压缩到一个位置.但令我困惑的是$${file_exe}是如何工作的.为什么需要双倍的$$?我想这与某些bash命令从makefile运行这一事实有关,但是我无法向自己解释为什么需要$$并且一个简单的$不起作用,因为这个命令正在运行一个子shell无论如何. 解决方法
需要区分是否要将$用作引入生成变量引用,例如${FOOBAR}或传递给shell的普通$.
make specification(章节宏)说要做后者,你必须使用$$,它被一个$替换并传递给shell.实际上,您的代码段显示为
for file_exe in `find . -name "zip_exe-*"`; do ./${file_exe} -d some/unzip/path/lib; done 到了shell. 样式注释:迭代由反引号创建的文件列表被认为是错误的样式,因为它可能会溢出ARG_MAX限制.最好一个一个地读取文件名 find . -name "zip_exe-*" | while read -r file_exe; do ./${file_exe} -d some/unzip/path/lib; done (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Ruby 设置 FTP 传输模式为 Passive
- Flexible, organic and biodegradable: Stanford
- c# – 使用Thread.Sleep等效的Parallel.ForEach
- Oracle常用小工具集合(生产积累)
- 每天4亿行SQLite订单大数据测试
- xml 绑定到 comboBox (DisplayMember和ValueMemb
- ruby-on-rails – 在创建会话时在Authlogic中指定
- [Swift]LeetCode699. 掉落的方块 | Falling Squa
- ajax set session can not save
- flash – 如何简单地将精灵附加到文本区域?
热点阅读