From: Simon Ruderich Date: Tue, 7 Apr 2009 22:44:55 +0000 (+0200) Subject: lib.sh: Move warning code to own function. X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=commitdiff_plain;h=222807c8b67d1c3429fc860e7924aa37e8d7d376 lib.sh: Move warning code to own function. --- 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 '$*'"