x
Loading
 Loading
Hello, Guest | Login | Register

The Unknown Power Tool: m4, Part Two

Dig deeper into m4, and look at included files, diversions, frozen files, and debugging and tracing.

Last month’s column (available online, beginning in May 2005, at http://www.linux-mag.com/2005-02/power_01.html) presented some basics of the m4 macro processor. m4 scans input text for defined symbols– macros– and replaces those symbols with other text and possibly with other symbols. For example, m4 can convert one language into another.
This month, let’s dig deeper into m4 and look at included files, diversions, frozen files, and debugging and tracing. Along the way, we’ll see some of the rough edges of m4’s minimalist language and explore workarounds. Before we start, though, here’s a warning from the GNU m4 info page:
Some people[ find] m4 to be fairly addictive. They first use m4 for simple problems, then take bigger and bigger challenges, learning how to write complex m4 sets of macros along the way. Once really addicted, users pursue writing of sophisticated m4 applications even to solve simple problems, devoting more time debugging their m4 scripts than doing real work. Beware that m4 may be dangerous for the health of compulsive programmers.
So take a deep breath… Good. Now let’s dig in again!

Included Files

m4’s built-in include() macro takes m4’s input from a named file until the end of that file, when the previous input resumes. sinclude() works like include() except that it won’t complain if the included file doesn’t exist.
If an included file isn’t in the current directory, GNU m4 searches the directories specified with the –I command-line…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Power Up Linux GUI Apps
  2. Tweeting from the Command Line with Twyt
  3. When Memory Serves You: Using ramfs and tmpfs
  4. Disk-O-Tech: Linux Disk Management
  5. Bang for the Buck
Follow Linux Magazine
Rackspace