导入使file进口时不会发生可变扩展

发布于 2025-02-06 09:30:29 字数 757 浏览 1 评论 0原文

我有一个带有一些变量带有变量扩展的shell脚本:

$ cat version
#!/bin/bash
export GIT_TAG=`git describe --tags --always --dirty`
export BUILD_NUM=${TRAVIS_BUILD_NUMBER:-${GIT_TAG}}
export VERSION="0.1.${BUILD_NUM}"

然后,我正在尝试将变量导入makefile:

$ cat Makefile
MAKEFLAGS += --warn-undefined-variables
include version
all:
    @echo $(VERSION)

但是,似乎变量扩展似乎不起作用:

$ make
Makefile:5: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
version:16: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
version:13: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
0.1.

有什么建议吗?

I have a shell script with some variables w/ variable expansions:

$ cat version
#!/bin/bash
export GIT_TAG=`git describe --tags --always --dirty`
export BUILD_NUM=${TRAVIS_BUILD_NUMBER:-${GIT_TAG}}
export VERSION="0.1.${BUILD_NUM}"

Then I'm trying to import the variables into a Makefile:

$ cat Makefile
MAKEFLAGS += --warn-undefined-variables
include version
all:
    @echo $(VERSION)

However it seems variable expansion isn't working:

$ make
Makefile:5: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
version:16: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
version:13: warning: undefined variable `TRAVIS_BUILD_NUMBER:-`git describe --tags --always --dirty`'
0.1.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文