在m4中,如何包含名称中包含环境变量的文件? [英] In m4, how do you include a file that has an environment variable in its name?

查看:204
本文介绍了在m4中,如何包含名称中包含环境变量的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不使用-I开关的情况下,在m4文本中包含一个相对于我的沙箱基础目录的文件.

I want to include a file based relative to my sandbox base directory inside of my m4 text without using the -I switch.

到目前为止,我已经弄清楚了如何使用sys调用来获取环境变量:

So far, I have figured out how to grab the environment variables using a sys call:

define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')')dnl

接下来,我要包含一个基于该环境变量的文件:

Next, I want to include a file based off that environment variable:

include(MODEL_ROOT/sw/lib/m4_macros/foreach2.m4)

我总共有:

define(MODEL_ROOT,`syscmd(`printf $MODEL_ROOT')')

MODEL_ROOT

MODEL_ROOT/sw/lib/m4_macros/foreach2.m4

include(MODEL_ROOT/sw/lib/m4_macros/foreach2.m4)

哪些印刷品:

/home/ross/sandbox

/home/ross/sandbox/sw/lib/m4_macros/foreach2.m4

/home/ross/sandboxforeach_example.m4:7: m4: Cannot open /sw/lib/m4_macros/foreach2.m4: No such file or directory

我知道include的常规语法是

I know that the normal syntax for includes is

include(`file.m4')

但是,如果我引用MODEL_ROOT/sw/lib/m4_macros/foreach2.m4,则m4为:

But if I quote MODEL_ROOT/sw/lib/m4_macros/foreach2.m4, then m4 like:

[...]
include(`MODEL_ROOT/sw/lib/m4_macros/foreach2.m4')

m4抱怨:

[...]
foreach_example.m4:7: m4: Cannot open MODEL_ROOT/sw/lib/m4_macros/foreach2.m4: No such file or directory

如何在路径中包含带有环境变量的文件?

How does one include a file with an environment variable in its path?

推荐答案

我认为您需要使用esyscmd而不是syscmd. esyscmd读取命令行输出.

I think you need to use esyscmd instead of syscmd. esyscmd reads command line output.

这篇关于在m4中,如何包含名称中包含环境变量的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆