m4-discuss
[Top][All Lists]
Advanced

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

Re: How to automatically replace date string with m4?


From: Eric Blake
Subject: Re: How to automatically replace date string with m4?
Date: Mon, 18 Jan 2016 07:58:53 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 01/17/2016 06:28 PM, Jack J. Woehr wrote:
> Peng Yu wrote:
>> I can use coreutils' date to generate a date with a date string as
>> follows.
>> date -d yesterday
>> date -d tomorrow
>>
> Well, you can start with:
> 
>    esyscmd(date)
>    Sun, Jan 17, 2016  6:24:03 PM
> 
> ... and proceed from there

In particular, you could:

define(`YESTERDAY', `esyscmd(`date -d yesterday')')

although the resulting date output will be scanned for further macros;
if you want to guarantee that it will not be re-expanded, then your
syscmd usage also needs to output m4 quoting characters:

define(`YESTERDAY',
  `esyscmd(`printf "`"; date -d yesterday; printf "'"')')

Note that the above gets tricky thanks to mixing shell and m4 quoting
rules; you may want to consider using changequote() to pick something
that mixes nicer with shell (the way autoconf picked [] rather than `'
for that very reason).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]