adapted to SML/NJ 1.09.27;
authorwenzelm
Thu, 24 Apr 1997 19:41:00 +0200
changeset 3046 6b7935317538
parent 3045 4ef28e05781b
child 3047 599cb28f8502
adapted to SML/NJ 1.09.27; minor cleanup;
lib/scripts/run-smlnj
--- a/lib/scripts/run-smlnj	Thu Apr 24 19:08:32 1997 +0200
+++ b/lib/scripts/run-smlnj	Thu Apr 24 19:41:00 1997 +0200
@@ -17,27 +17,38 @@
 }
 
 
-## prepare databases
+## version specific stuff
 
 EXIT=""
-if [ -z "$INFILE" ]; then
-  case "$ML_SYSTEM" in
-    smlnj-1.0[678])
-      EXIT="val exit = System.Unix.exit;"
-      ;;
-    smlnj-1.09*)
-      EXIT="fun exit 0 = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;"
+COMMIT=""
+FIXNAME=""
+
+case "$ML_SYSTEM" in
+  smlnj-1.0[678]*)
+    EXIT="val exit = System.Unix.exit;"
+    COMMIT="fun commit () = not (exportML\"$OUTFILE\");"
+    COMMIT_RO='fun commit () = (output (std_err, "Error - Database is not opened for writing.\\n"); false);'
     ;;
-  esac
+  smlnj-1.09*)
+    EXIT="fun exit 0 : unit = OS.Process.exit OS.Process.success | exit _ = OS.Process.exit OS.Process.failure;"
+    COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");"
+    COMMIT_RO='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\\n"); false);'
+    FIXNAME=true
+    ;;
+esac
+
+
+## prepare databases
+
+DB="$INFILE"
+
+if [ -n "$DB" ]; then
+  DB="@SMLload=$INFILE"
+  EXIT=""
 fi
 
-DB="$INFILE"
-[ -n "$DB" ] && DB="@SMLload=$INFILE"
-
-COMMIT="fun commit () = not (exportML\"$OUTFILE\");"
-
 if [ -z "$OUTFILE" ]; then
-  COMMIT='fun commit () = (output (std_err, "Error - Database is not opened for writing.\n"); false);'
+  COMMIT="$COMMIT_RO"
 elif [ -n "$INFILE" -a ! "$INFILE" -ef "$OUTFILE" ]; then
   [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
   cp "$INFILE" "$OUTFILE" || fail_out
@@ -46,7 +57,7 @@
 [ -n "$OUTFILE" -a -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
 
 MLTEXT="$EXIT $COMMIT $MLTEXT"
-MLEXIT="commit();"
+MLEXIT="commit ();"
 
 
 ## run it!
@@ -64,4 +75,11 @@
   RC=$?
 fi
 
+#fix heap file name
+if [ -n "$OUTFILE" -a -n "$FIXNAME" ]; then
+  eval $($ML_HOME/.arch-n-opsys)
+  SUFFIX=$ARCH-$OPSYS
+  [ -f $OUTFILE.$SUFFIX ] && mv $OUTFILE.$SUFFIX $OUTFILE
+fi
+
 exit $RC