News for hackers. Stuff that matters.
Re:Notes on the M4 Macro Language (2008) by enasterosophes on Thursday May 19, 2022 @06:30PM (#31441004)
I use m4 to generate my ssh config files. Otherwise managing the complexity of hundreds of servers over multiple subdomains all with different requirements for access and authentication would be prohibitive, especially given that openssh's config format only has a cursory understanding of how to define patterns with regex or cidr.
Re:Notes on the M4 Macro Language (2008) by harshreality on Friday May 20, 2022 @12:46AM (#31443453)
They have different design philosophies, but dhall[1] will generally do that sort of thing, and anyone who has dabbled with functional programming and hates baroque syntax common to many languages from the early days of computing may prefer dhall over something like m4.

[1] https://dhall-lang.org/

Re:Notes on the M4 Macro Language (2008) by hdjjhhvvhga on Friday May 20, 2022 @03:26AM (#31444349)
Of course you are right and hundreds of such tools exist. The only reason we are talking about m4 here is that is basically everywhere for legacy reasons.
Re:Notes on the M4 Macro Language (2008) by enasterosophes on Sunday May 22, 2022 @05:59PM (#31473223)
Correct. I was motivated to use m4 to solve the problem I had, because m4 is ubiquitous. I wanted to know more about it, and I wanted my config files to be generatable on any machine where I spend some time.
Re:Notes on the M4 Macro Language (2008) by perfecthjrjth on Thursday May 26, 2022 @11:30AM (#31519574)
Can you please share a sample m4 script to generate ssh config? Just curious how you have solved complicated stuff, patterns, etc.
Re:Notes on the M4 Macro Language (2008) by e40 on Thursday May 19, 2022 @07:39PM (#31441625)
I considered that just the other day. Ended up using cpp instead.
Re:Notes on the M4 Macro Language (2008) by imglorp on Thursday May 19, 2022 @08:01PM (#31441786)
Another simple option is envsubst which does one thing well.
Re:Notes on the M4 Macro Language (2008) by nick__m on Thursday May 19, 2022 @08:54PM (#31442144)
I used envsubst when I can but as far as I know you cannot do loop using envsubst. When you use the c preprocessor or php, m4, etc..., you can.
Re:Notes on the M4 Macro Language (2008) by imglorp on Friday May 20, 2022 @12:45PM (#31449842)
Nah, that's what I meant. It does $-expansion and that's it. If you need conditionals and loop you need templates and macros like others are saying: m4, cpp, handlebars, whatever.

I use it as a low-brain template engine to do only that.

Re:Notes on the M4 Macro Language (2008) by morelisp on Thursday May 19, 2022 @11:51PM (#31443156)
I use envsubst a lot, but without - and + forms it's hard to say it does it well.