Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/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
Bash makefile循环变量_Bash_Loops_Makefile_Gnu - Fatal编程技术网

Bash makefile循环变量

Bash makefile循环变量,bash,loops,makefile,gnu,Bash,Loops,Makefile,Gnu,makefile中有以下内容: RESULT=ab nums: number=1 ; while [[ $$number -le $(DIRS_NUM) ]] ; do \ now=`echo $(CURR_DIR) | cut -d "/" -f 1-$$number` ;\ **RESULT = $$now;\** echo $(RESULT);\ ((number = number + 1)) ; \

makefile中有以下内容:

RESULT=ab
nums:
    number=1 ; while [[ $$number -le $(DIRS_NUM) ]] ; do \

        now=`echo $(CURR_DIR) | cut -d "/" -f 1-$$number` ;\

        **RESULT = $$now;\**

        echo $(RESULT);\

        ((number = number + 1)) ; \    
    done

我想更新
结果
变量,但我不确定如何更新。

无法从规则中更新makefile变量。您可以使用$(shell cmd)宏来执行命令并从其输出流中获取值,但这是您所能做到的。一个简单的例子:

X := $(shell echo 5)
现在
X
将具有值
5


注意这里使用的是
:=
,而不是简单的
=
。这会立即展开右侧的所有内容,而不是每次引用
X

为什么?您还计划如何处理
结果