Re: m4 macro expansion problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 25, 2021, at 12:06 PM, Sébastien Hinderer wrote:
> Zack Weinberg (2021/08/25 11:39 -0400):
> > m4_syscmd is a primitive, and it doesn't expand its argument, so you need to expand PKG_VERSION first:
> >
> > m4_syscmd([cat > VERSION << \END_OF_VERSION_FILE
> > ]PKG_VERSION[
> >
> > # Some comments about the format of version numbers
> > END_OF_VERSION_FILE
> > ])
> I double-checked my code and there was no \ before END_OF_VERSION_FILE
> and the code was working so may I ask why you added one in your code?

That's an extra defensive measure.  It makes the *shell* treat the here document as quoted, so that if your PKG_VERSION or your commentary ever happens to contain shell metacharacters they won't do anything surprising.  I habitually add this to here documents unless there's a reason to *want* shell variable expansion (for instance) in some particular here document.

zw





[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux