On 8/23/23 11:00 AM, Michael Grant via mailop wrote:
I've been waiting for someone to layer something like yaml on top of sendmail's M4.

First: It's not /Sendmail/'s M4. M4 is it's own stand alone language -- one I find quite useful -- which Sendmail happened to utilize.

Aside: Is it IBM's COBOL if nobody else uses COBOL any more? Nope, it's still just COBOL used by IBM.

I've not done anything with YAML in M4.  I rather dislike YAML.

But I have written what a few different things in M4 that have made my life a LOT easier.

 - ~/.ssh/config file manager combined with make and sed
 - /etc/hosts file manager -- respin of the previous
 - rwhois data manager
 - Q & A formater.

The first two were fixed position parameters. So I ended up with multiple macros calls that were effectively:

   host(`hostname', `username', , , , `jump host')dnl

I disliked the fixed position parameters so I created the third and forth as more quasi object oriented.

I could do things like the following:

        router(
                name(`router1')
                ip(`192.0.2.1/24')
                ip(`198.51.100.1/24')
                rack(`A1')
        )dnl
        router(
                name(`router2')
                ip(`192.0.2.2/24')
                ip(`203.0.113.2/24')
                rack(`B2')
        )dnl
        router(
                name(`router3')
                ip(`198.51.100.3/24')
                ip(`203.0.113.3/24')
                rack(`C3')
        )dnl
        router(
                name(`router13')
                ip(`192.0.2.13/24')
                ip(`198.51.100.13/24')
                ip(`203.0.113.13/24')
                ip(`100.64.13.13/12')
                rack(`D4')
        )dnl

I could use the same M4 macro calls to different macro definitions to produce different results.

It could easily convert the macros into just about any format of output that I wanted. It was calculating the following given the IP and (sub)netmask:

 - subnet
 - broadcast
 - Cisco wildcard

It made it really trivial to maintain rwhois data for a network.

The fourth Q & A formatter took things like this the following:

   question(`What is the square root of three?')dnl

And converted it to something like the following:

   Q:  What is the square root of three?
   A:
   C:

The idea being I could maintain my list of questions as a set of individual lines each calling the question macro. Then when I needed to, I could choose questions at random / shuffle / what have you and run them through M4 and get a series of question, answer, comment blocks output ready to be used in the interview process.

M4 is great at converting one form of text to another form of text.

It's really only your imagination that is the limit of how you convert things.

Come on, admit, i know some of you all have thought this too.

Nope, not YAML.  Many other things with M4 have crossed through my mind.

Yes, Sendmail is what introduced me to M4. But M4 in no way, shape, or form limited to, much less belong to Sendmail.



Grant. . . .
_______________________________________________
mailop mailing list
mailop@mailop.org
https://list.mailop.org/listinfo/mailop

Reply via email to