Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables Makefile及其使用$$_Variables_Unix_Makefile - Fatal编程技术网

Variables Makefile及其使用$$

Variables Makefile及其使用$$,variables,unix,makefile,Variables,Unix,Makefile,因此,我有一个Makefile,其中包含我试图理解的以下代码: for file_exe in `find . -name "zip_exe-*"`; do \ ./$${file_exe} -d $(UNZIP_PATH)/lib; \ done 据我所知,这段代码将试图找到一些可执行的zip文件,并将这些zip文件解压缩到一个位置。但让我困惑的是$${file_exe}是如何工作的。为什么需要双重$$?我想这与某些bash命令是从makefile运行的事实有关,但我无法向自己解释为

因此,我有一个Makefile,其中包含我试图理解的以下代码:

for file_exe in `find . -name "zip_exe-*"`; do \
    ./$${file_exe} -d $(UNZIP_PATH)/lib; \
done

据我所知,这段代码将试图找到一些可执行的zip文件,并将这些zip文件解压缩到一个位置。但让我困惑的是
$${file_exe}
是如何工作的。为什么需要双重
$$
?我想这与某些bash命令是从makefile运行的事实有关,但我无法向自己解释为什么需要
$
,而简单的
$
不起作用,因为该命令正在运行一个子shell。

Make需要区分是希望
$
用作引入Make变量引用,例如
${FOOBAR}
,还是作为传递给shell的普通$。(宏部分)说明,要执行后一种操作,必须使用
$
,它被一个
$
替换并传递给shell。实际上,您的代码片段读作

for file_exe in `find . -name "zip_exe-*"`; do \
   ./${file_exe} -d some/unzip/path/lib; \
done
去贝壳

样式说明:对backticks创建的文件列表进行迭代被认为是错误的样式,因为它可能会溢出ARG_MAX限制。最好使用

find . -name "zip_exe-*" | \
while read -r file_exe; do \
   ./${file_exe} -d some/unzip/path/lib; \
done

$
表示shell将其解释为
$
$(解压路径)
在被shell解释之前由make展开。@Petesh:你应该回答这个问题。