m4 (GNU M4) 1.4.18 Operating System: Ubuntu 20.04 LTS Kernel: Linux 5.4.0-33-generic Architecture: x86-64
### 1. if i define $# as macro body then error occurred $ m4 <<\@ define(`foo', $2) foo(100,200,300) @ 200 # OK --------------------- $ m4 <<\@ define(`foo', $#) foo(100,200,300) @ m4:stdin:1: ERROR: end of file in argument list ----------------------- $ m4 <<\@ define(`foo', `$#') # must quote `$#' foo(100,200,300) @ 3 # OK ################################################### ### 2. if i invocate m4wrap just once then return macro body $ m4 <<\@ define(`foo', 11111)dnl define(`bar', 22222)dnl define(`zoo', 33333)dnl m4wrap(`zoo')dnl 99999 @ 99999 33333 <---- not zoo but 33333 $ m4 <<\@ define(`foo', 11111)dnl define(`bar', 22222)dnl define(`zoo', 33333)dnl m4wrap(`foo')dnl m4wrap(`bar')dnl m4wrap(`zoo')dnl 99999 @ 99999 zoobarfoo