From: Simon Ruderich Date: Mon, 16 Feb 2009 13:14:21 +0000 (+0100) Subject: Add m4.sh to process files with m4. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=856e63f63eb829a53ae5f6f6957d93717a561f86;p=config%2Fdotfiles.git Add m4.sh to process files with m4. The syntax is `m4.sh filename args-to-m4` which processes filename.m4 and writes it to filename. Additional arguments are passed to m4. This script differs from just calling m4 that it writes the header "Do not edit this file" to the generated file to prevent accidental changes. --- diff --git a/m4.sh b/m4.sh new file mode 100755 index 0000000..760ff0e --- /dev/null +++ b/m4.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# m4 wrapper script which uses $1.m4 as template file, feeds it to m4 and +# writes it to m4 with a warning at the beginning to not edit the generated +# file. +# +# All arguments to this script (except the first which is the filename) are +# passed to m4. + + +# First argument is file name. +file=$1 +shift + +# Write a warning to the generated file. +echo "###################################" > $file +echo "# WARNING! DO NOT EDIT THIS FILE! #" >> $file +echo "###################################" >> $file +echo >> $file +echo "# It was generated from $file.m4 on `date`." >> $file +echo >> $file + +# Process $1.m4 with m4 using the given options. +m4 $* $file.m4 >> $file