首页 Linux linux – bash / Makefile中双符号的意思是什么?

linux – bash / Makefile中双符号的意思是什么?

在Makefile中插入一个 shell脚本时,我们有(?)使用一个双重美元符号($$)来引用变量.为什么? for number in 1 2 3 4 ; do echo $$number ; done 根据 gnu make official doc: Variable and function references in recipes have identical synt

在Makefile中插入一个
shell脚本时,我们有(?)使用一个双重美元符号($$)来引用变量.为什么?

for number in 1 2 3 4 ; do \
    echo $$number ; \
done

解决方法

根据
gnu make official doc:

Variable and function references in recipes have identical syntax and
semantics to references elsewhere in the makefile. They also have the
same quoting rules: if you want a dollar sign to appear in your
recipe,you must double it (‘$$’). For shells like the default shell,
that use dollar signs to introduce variables,it’s important to keep
clear in your mind whether the variable you want to reference is a
make variable (use a single dollar sign) or a shell variable (use two
dollar signs).

简而言之:

> makefile variable =>使用一个美元符号> shell variable =>使用两个美元的标志

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/zhonghe/fwq/linux/20210124/16973.html
上一篇
下一篇

作者: dawei

【声明】:青岛站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

返回顶部