Index: trunk/Ohana/src/opihi/lib.shell/startup.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 4689)
+++ trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 5900)
@@ -1,39 +1,29 @@
 # include "opihi.h"
 
-/* program-independent initialization */
-void startup (int argc, char **argv) {
+/* program-independent initialization
+ * these steps do not depend on the opihi implementation
+ * (ie, the supplied commands or data structures)
+ */
 
-  long A, B;
-    
-  signal (SIGINT, SIG_IGN);
+void general_init (int argc, char **argv) {
 
   /* init srand for rnd numbers elsewhere */
+  long A, B;
   A = time(NULL);
   for (B = 0; A == time(NULL); B++);
   srand48(B);
  
-  if (0) {
-    /* fix the history list to remove the timestamp */
-    char *c;
-    int i;
-    HIST_ENTRY **entry;
-    
-    entry = history_list ();
-    if (entry != (HIST_ENTRY **) NULL) {
-      for (i = 0; entry[i]; i++) {
-	if ((strlen (entry[i][0].line) > 19) &&
-	    (entry[i][0].line[2] == '/') && 
-	    (entry[i][0].line[5] == '/') && 
-	    (entry[i][0].line[11] == ':') && 
-	    (entry[i][0].line[14] == ':') && 
-	    (entry[i][0].line[17] == ':')) {
-	  c = entry[i][0].line + 19;
-	  memmove (entry[i][0].line, c, strlen(c) + 1);
-	}
-      }
-    }
+  /* set signals */
+  signal (SIGINT, SIG_IGN);
+
+  /* load config data (.ptolemyrc) */
+  if (!ConfigInit (&argc, argv)) {
+    fprintf (stderr, "can't find config file. some functions will be unavailable\n");
   }
-  
-  {
+
+  return;
+}
+
+void startup (int argc, char **argv) {
     
     int i, N, status, ONLY_INPUT, LOAD_RC;
@@ -57,6 +47,40 @@
   */
 
-    if (!ConfigInit (&argc, argv)) {
-      fprintf (stderr, "can't find config file. some functions will be unavailable\n");
+
+
+  /* check history file permission */
+  {
+    FILE *f;
+    char *opihi_history;
+
+    opihi_history = get_variable ("RCFILE");
+    f = fopen (opihi_history, "a");
+    if (f == NULL) /* no current history file here */
+      fprintf (stderr, "can't save history.\n");
+    else
+      fclose (f);
+    stifle_history (200);
+    read_history (opihi_history);
+  }
+
+  if (0) {
+    /* fix the history list to remove the timestamp */
+    char *c;
+    int i;
+    HIST_ENTRY **entry;
+    
+    entry = history_list ();
+    if (entry != (HIST_ENTRY **) NULL) {
+      for (i = 0; entry[i]; i++) {
+	if ((strlen (entry[i][0].line) > 19) &&
+	    (entry[i][0].line[2] == '/') && 
+	    (entry[i][0].line[5] == '/') && 
+	    (entry[i][0].line[11] == ':') && 
+	    (entry[i][0].line[14] == ':') && 
+	    (entry[i][0].line[17] == ':')) {
+	  c = entry[i][0].line + 19;
+	  memmove (entry[i][0].line, c, strlen(c) + 1);
+	}
+      }
     }
 
