]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
lib.sh: Move warning code to own function.
authorSimon Ruderich <simon@ruderich.org>
Tue, 7 Apr 2009 22:44:55 +0000 (00:44 +0200)
committerSimon Ruderich <simon@ruderich.org>
Tue, 7 Apr 2009 22:44:55 +0000 (00:44 +0200)
lib.sh

diff --git a/lib.sh b/lib.sh
index 9e2308d6adf988de977116d7b28713e52c077fce..6cd3d2f8d79adf7cb662ae6347fd394c8966e172 100644 (file)
--- a/lib.sh
+++ b/lib.sh
@@ -72,6 +72,17 @@ link() {
     unset pwd base source target
 }
 
     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.
 #
 # 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
 
     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 '$*'"
 
     # Process $1.m4 with m4 using the given options.
     echo "m4(): generating '$file' from '$file.m4' with options '$*'"