Index: trunk/Ohana/src/opihi/dvo/Makefile
===================================================================
--- trunk/Ohana/src/opihi/dvo/Makefile	(revision 5850)
+++ trunk/Ohana/src/opihi/dvo/Makefile	(revision 5900)
@@ -45,4 +45,5 @@
 $(SDIR)/calextract.$(ARCH).o      	\
 $(SDIR)/calmextract.$(ARCH).o     	\
+$(SDIR)/catdir.$(ARCH).o             	\
 $(SDIR)/ccd.$(ARCH).o             	\
 $(SDIR)/cmatch.$(ARCH).o	  	\
Index: trunk/Ohana/src/opihi/dvo/catdir.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5850)
+++ trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5900)
@@ -3,5 +3,5 @@
 int catdir_define (int argc, char **argv) {
   
-  int VERBOSE;
+  int status, N, VERBOSE;
 
   VERBOSE = FALSE;
Index: trunk/Ohana/src/opihi/dvo/dvo.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5850)
+++ trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5900)
@@ -8,5 +8,5 @@
 
 /* program-dependent initialization */
-void initialize (int argc, char **argv) {
+void program_init (int argc, char **argv) {
   
   auto_break = TRUE;
@@ -18,5 +18,5 @@
   InitDVO ();
 
-  if (SetCATDIR (NULL, TRUE)) {
+  if (!SetCATDIR (NULL, TRUE)) {
     fprintf (stderr, "CATDIR is not defined\n");
   }
@@ -28,20 +28,9 @@
   set_str_variable ("PROMPT", opihi_prompt);
   set_str_variable ("RCFILE", opihi_rcfile);
+
 # ifdef HELPDIR_DEFAULT
   set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
 # endif
 
-  { /* check history file permission */
-    FILE *f;
-    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);
-  }
-
-  signal (SIGINT, SIG_IGN);
   return;
 }
Index: trunk/Ohana/src/opihi/dvo/init.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/init.c	(revision 5850)
+++ trunk/Ohana/src/opihi/dvo/init.c	(revision 5900)
@@ -6,4 +6,5 @@
 int calmextract	    PROTO((int, char **));
 int catlog	    PROTO((int, char **));
+int catdir_define   PROTO((int, char **));
 int ccd		    PROTO((int, char **));
 int cmatch	    PROTO((int, char **));
@@ -61,4 +62,5 @@
   {"calextract",  calextract,   "extract photometry calibration"},
   {"calmextract", calmextract,  "extract photometry calibration"},
+  {"catdir",      catdir_define,"re-define CATDIR"},
   {"ccd",         ccd,          "plot color-color diagram"},
   {"cmatch",      cmatch,       "match two catalogs"},
Index: trunk/Ohana/src/opihi/dvo/region_list.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5850)
+++ trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5900)
@@ -30,4 +30,11 @@
   if (VarConfig ("SKYFILE",  "%s", skyfile) == NULL) skyfile[0] = 0;
   if (VarConfig ("SKYDEPTH", "%d", &skydepth) == NULL) skydepth = 2;
+
+  if (verbose) {
+      fprintf (stderr, "CATDIR %s\n", catdir);
+      fprintf (stderr, "GSCFILE %s\n", gscfile);
+      fprintf (stderr, "SKYFILE %s\n", skyfile);
+      fprintf (stderr, "SKYDEPTH %d\n", skydepth);
+  }
 
   /* load the SkyTable at this point */
@@ -81,5 +88,4 @@
   int Ngraph;
   Graphdata graphsky;
-  SkyTable *sky;
   SkyList *skylist;
   char filename[256];
Index: trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- trunk/Ohana/src/opihi/include/shell.h	(revision 5850)
+++ trunk/Ohana/src/opihi/include/shell.h	(revision 5900)
@@ -44,5 +44,6 @@
 
 /*** basic opihi shell functions ***/
-void          initialize            	PROTO((int argc, char **argv));
+void          general_init            	PROTO((int argc, char **argv));
+void          program_init            	PROTO((int argc, char **argv));
 void          startup               	PROTO((int argc, char **argv));
 int           multicommand          	PROTO((char *line));
Index: trunk/Ohana/src/opihi/lib.shell/opihi.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 5850)
+++ trunk/Ohana/src/opihi/lib.shell/opihi.c	(revision 5900)
@@ -8,5 +8,6 @@
   pid_t ppid;
 
-  initialize (argc, argv);
+  general_init (argc, argv);
+  program_init (argc, argv);
   startup (argc, argv);
   prompt = get_variable("PROMPT");
@@ -45,2 +46,12 @@
   }
 }
+
+/* 
+   startup sequence:
+
+   - general_init
+   - program_init
+   - startup (exit if non-interactive)
+   - welcome
+
+*/
Index: trunk/Ohana/src/opihi/lib.shell/startup.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 5850)
+++ 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);
+	}
+      }
     }
 
