加入收藏 | 设为首页 | 会员中心 | 我要投稿 阜阳站长网 (https://www.0558zz.com/)- 科技、建站、内容创作、云计算、网络安全!
当前位置: 首页 > 综合聚焦 > Linux > 正文

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

发布时间:2021-01-24 07:35:30 所属栏目:Linux 来源:互联网
导读:在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 =>使用两个美元的标志

(编辑:阜阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读