bug or feature in m4?

Jens Schweikhardt schweikh at schweikhardt.net
Wed Apr 30 07:35:09 PDT 2003


hello, world\n

I'm not sure if this is a bug, feature or a misunderstanding of mine. I
would expect the m4 syscmd macro to be replaced at the point where it
appears in the input, but apparently its output appears at the very
beginning. How to repeat:

	$ m4 > x
	hello
	world
	syscmd(date)dnl
	foo
	bar
    ^D
	$ cat x
	Wed Apr 30 16:21:07 CEST 2003
	hello
	world
	foo
	bar

My expectation is to see

	hello
	world
	Wed Apr 30 16:21:07 CEST 2003
	foo
	bar

POSIX 2001 (SUSv3) says

  syscmd

    The syscmd macro shall interpret its first argument as a shell
    command line. The defining text shall be the string result of that
    command. No output redirection shall be performed by the m4 utility.
    The exit status value from the command can be retrieved using the
    sysval macro.

The esyscmd macro does what I expect, however it is not POSIX and I'd
like to write portable m4 input files.

Regards,

	Jens
-- 
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)


More information about the freebsd-standards mailing list