3 ms·
Please write more to this story
by JoelMcCracken 3y ago
Please write more to this story
- gizmo686 3y agoNot "this" story. Everything above has happened on several projects. The cat thing comes up because it is tricky to expand two macros next to each other without whitespace. So if you do: define(`foo',`hello') define(`bar',`world') foo bar foobar You will get: hello world foobar Working around this gets tricky, so someone inevitably ends up writing a cat-like macro such that you can do cat(foo,bar) To get helloworld. A side effect of this is that now "cat" is really "cat()" which expands to "". You can work around this by doing `cat'. However, if `cat' is used as an argument to another macro (such as a for loop), the quotation only prevents escaping the first time. When the for macro is expanded, the quotation marks are stripped, giving you just "cat", which gets expanded again. A correctly written for macro would add new quotes as needed, but I have never seen someone correctly write such a macro without just copying it. Not sure if I have seen this interaction specifically with for and cat, but I have seen an interaction like it on almost every project that used m4.
- mhitza 3y agoYou can place an empty "expansion" in that line to get the behavior you want without an additional cat-like function foo`'bar I only know of this feature because recently read the manual page for m4, and it's mentioned rather early in there, but might have been not as well emphasized in past iterations of the manual.
- gnubison 3y agoFor completions sake, though, the easy way to do it is: foo`'bar The empty quotes make foo and bar separate words.