[MLton-commit] r6142

Vesa Karvonen vesak at mlton.org
Thu Nov 8 11:20:18 PST 2007


Don't modify generated files unnecessarily.
----------------------------------------------------------------------

U   mltonlib/trunk/org/mlton/vesak/use-lib/unstable/Make.sh

----------------------------------------------------------------------

Modified: mltonlib/trunk/org/mlton/vesak/use-lib/unstable/Make.sh
===================================================================
--- mltonlib/trunk/org/mlton/vesak/use-lib/unstable/Make.sh	2007-11-08 13:17:44 UTC (rev 6141)
+++ mltonlib/trunk/org/mlton/vesak/use-lib/unstable/Make.sh	2007-11-08 19:20:16 UTC (rev 6142)
@@ -7,7 +7,7 @@
 
 set -e
 
-code="$(cat public/use-lib.sig detail/use-lib.sml public/export.sml)"
+sources="public/use-lib.sig detail/use-lib.sml public/export.sml"
 
 function gen {
     echo "(* Copyright (C) 2007 Vesa Karvonen
@@ -16,16 +16,22 @@
  * See the LICENSE file or http://mlton.org/License for details.
  *)
 
-(* WARNING: This file was generated by the $(basename $0) script. *)" > "$1.use"
+(* WARNING: This file was generated by the $(basename $0) script. *)" > .tmp
 
-    echo "$code"                                \
+    cat $sources                                \
   | grep -v '^ *(\?\*'                          \
   | sed -e "s/\\\${SML_COMPILER}/\"$1\"/g"      \
         -e "s/\\\${SILENT}/$(echo -n $2)/g"     \
         -e "s/\\\${VERBOSE}/$(echo -n $3)/g"    \
         -e "s/\\\${PRELUDE}/$(echo -n $4)/g"    \
-  >> "$1.use"
-    echo "Wrote $1.use"
+  >> .tmp
+
+    if test "$(cat $1.use)" != "$(cat .tmp)" ; then
+        mv .tmp $1.use
+        echo "Wrote $1.use"
+    else
+        rm .tmp
+    fi
 }
 
 gen polyml                                      \




More information about the MLton-commit mailing list