X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=blobdiff_plain;f=lib.sh;h=6cd3d2f8d79adf7cb662ae6347fd394c8966e172;hp=9e2308d6adf988de977116d7b28713e52c077fce;hb=222807c8b67d1c3429fc860e7924aa37e8d7d376;hpb=e3b75caad520a1711c4fa5966950b1a3b32117a9 diff --git a/lib.sh b/lib.sh index 9e2308d..6cd3d2f 100644 --- a/lib.sh +++ b/lib.sh @@ -72,6 +72,17 @@ link() { unset pwd base source target } +# Write a warning to $1 to make clear it should not be modified. $2 is the +# source for the generated file. +setup_warning() { + echo "###################################" > $1 + echo "# WARNING! DO NOT EDIT THIS FILE! #" >> $1 + echo "###################################" >> $1 + echo >> $1 + echo "# It was generated from $2 on `date`." >> $1 + echo >> $1 +} + # m4 wrapper which uses $1.m4 as template file, feeds it to m4 and writes it # to $1 with a warning at the beginning to not edit the generated file. # @@ -86,13 +97,8 @@ m4() { 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 + # Write a warning to the generated file to not edit it. + setup_warning $file $file.m4 # Process $1.m4 with m4 using the given options. echo "m4(): generating '$file' from '$file.m4' with options '$*'"