M4:如何从脚本后跟文件中删除前导空格?

M4: How to drop leading whitespace from script followed by file?

如果我有一个包含许多命令的 m4 脚本:

define(this, that)
define(or,this)
define(other,thing)

我打电话给:

$: m4 script.m4 my_file

输出为:

# N newlines for the N commands in the script
# first line of my file

是否可以在调用 m4 时抑制脚本读入产生的 N newlines,或者我是否必须将其包装在某些调用命令集(如 sedgrep)?

您可以使用 dnl 宏删除 define 的新行。例如。来自 this tutorial:

The define macro itself – including its two arguments – expands to an empty string, that is, it produces no output. However the newline at the end of the AUTHOR definition above would be echoed to the output. If a blank line added to the output is a problem then you can suppress it using the “delete to newline” macro:

 define(AUTHOR, W. Shakespeare)dnl

There is no space between the end of the macro and the dnl: if there were then that space would be echoed to the output.