Index: /trunk/Ohana/src/opihi/lib.shell/VectorIO.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/VectorIO.c	(revision 41160)
+++ /trunk/Ohana/src/opihi/lib.shell/VectorIO.c	(revision 41161)
@@ -110,6 +110,50 @@
 }
 
+// insert a new header line, return end pointer
+char *gfits_insert_header_line (Header *header, char *endptr, char *newline) {
+
+  if (0) {
+    char temp1[32], temp2[32];
+    memset (temp1, 0, 32);
+    memset (temp2, 0, 32);
+
+    if (endptr) {
+      memcpy (temp1, endptr, 8);
+    }
+    memcpy (temp2, newline, 8);
+    fprintf (stderr, "insert: %s : %s\n", temp1, temp2);
+  }
+
+  /* find the END of the header, if not supplied */
+  if (!endptr) {
+    endptr = gfits_header_field (header, "END", 1);
+    if (endptr == NULL) return NULL; 
+  }
+
+  /* is there enough space for 1 more line? */
+  if (header[0].datasize - (endptr - (header[0].buffer)) < 2*FT_LINE_LENGTH) {
+    // no, so expand by a full header block (FT_RECORD_SIZE = 32*80 = 2880)
+    header[0].datasize += FT_RECORD_SIZE;
+    REALLOCATE (header[0].buffer, char, header[0].datasize);
+    // re-find the "END" marker, in case new memory block is used 
+    endptr = gfits_header_field (header, "END", 1);
+    if (endptr == NULL) return NULL; 
+    memset (endptr + FT_LINE_LENGTH, ' ', FT_RECORD_SIZE);
+  }
+
+  /* push END line back 1 */
+  memmove ((endptr + FT_LINE_LENGTH), endptr, FT_LINE_LENGTH);
+  memset (endptr, ' ', FT_LINE_LENGTH);
+
+  strncpy (endptr, newline, 80);
+  endptr += FT_LINE_LENGTH;
+
+  return endptr;
+}
+  
+static char *rawkeywords[] = {"SIMPLE", "BITPIX", "NAXIS", "PCOUNT", "GCOUNT", "EXTEND", "EXTNAME", "BSCALE", "BZERO", "TFIELDS", "TFORM", "TZERO", "TSCAL", "        ", NULL};
+
 // write a set of vectors to a FITS file (vectors names become fits column names)
-int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile) {
+int WriteVectorTableFITS (char *filename, char *extname, Header *extraheader, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile) {
   
   Header rawheader;
@@ -139,5 +183,5 @@
   rawtable.header = &rawheader;
   if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format, (compress != NULL))) goto escape;
-  // NOTE : for compression, the table is constructed in native by order 
+  // NOTE : for compression, the table is constructed in native byte order 
 
   FTable *outtable = &rawtable;
@@ -163,4 +207,5 @@
 
   if (!append) {
+    // generate a blank PHU header
     Header header;
     Matrix matrix;
@@ -176,4 +221,30 @@
   }
 
+  if (extraheader) {
+    // copy keywords which are not the standard or table keywords
+    char *buf = extraheader->buffer;
+    char *endptr = NULL;
+    for (int i = 0; i < extraheader->datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) {
+
+      if (0) { 
+	char temp1[32];
+	memset (temp1, 0, 32);
+	memcpy (temp1, buf, 8);
+	fprintf (stderr, "buffer: %s\n", temp1);
+      }
+
+      for (int j = 0; rawkeywords[j] != NULL; j++) {
+	if (!strncmp (buf, rawkeywords[j], strlen(rawkeywords[j]))) goto skip_insert;
+      }
+      endptr = gfits_insert_header_line (outheader, endptr, buf);
+      if (!endptr) {
+	gprint (GP_ERR, "failed to update FITS header with extra keywords\n");
+	return (FALSE);
+      }
+    skip_insert:
+      continue;
+    }
+  }
+
   // write the actual table data
   gfits_fwrite_Theader (f, outheader);
Index: /trunk/Ohana/src/opihi/lib.shell/multicommand.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/multicommand.c	(revision 41160)
+++ /trunk/Ohana/src/opihi/lib.shell/multicommand.c	(revision 41161)
@@ -63,4 +63,6 @@
 
   p = line; 
+  int Nline = strlen(line);
+  
   done = FALSE;
   status = TRUE;
@@ -74,82 +76,95 @@
     tmpline = strncreate (p, q - p);
     stripwhite (tmpline);
-    if (*tmpline) {
+    myAssert (tmpline, "oops");
 
-      if (bufferPending) {
-	// flush old messages
-	ExpectMessage (server, 0.2, &message);
-	bufferPending = FALSE;
+    // empty command, free and continue
+    if (*tmpline == 0) {
+      free (tmpline);
+      if (q == line + Nline) {
+	done = TRUE;
+      } else {
+	p = q + 1;
+	myAssert (p - line <= Nline, "oops");
       }
+      continue;
+    }
 
-      status = command (tmpline, &outline, verbose);
+    if (bufferPending) {
+      // flush old messages
+      ExpectMessage (server, 0.2, &message);
+      bufferPending = FALSE;
+    }
 
-      if (status == -1) {
-	if (server) {
-	  // send the command to the server instead
-	  if (!SendMessage (server, "%s", outline)) {
-	    switch (errno) {
-	      case EPIPE:
-		gprint (GP_ERR, "server connection has died\n");
-		exit (32);
-	      default:
-		gprint (GP_ERR, "server is busy...32\n");
-		bufferPending = TRUE;
-		goto escape;
-	    }
+    // input tmpline is freed by command
+    status = command (tmpline, &outline, verbose);
+
+    if (status == -1) {
+      if (server) {
+	// send the command to the server instead
+	if (!SendMessage (server, "%s", outline)) {
+	  switch (errno) {
+	    case EPIPE:
+	      gprint (GP_ERR, "server connection has died\n");
+	      exit (32);
+	    default:
+	      gprint (GP_ERR, "server is busy...32\n");
+	      bufferPending = TRUE;
+	      goto escape;
 	  }
+	}
 
-	  // receive the command exit status
-	  if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
-	    switch (errno) {
-	      case EPIPE:
-		gprint (GP_ERR, "server connection has died\n");
-		exit (33);
-	      default:
-		gprint (GP_ERR, "server is busy...33\n");
-		bufferPending = TRUE;
-		goto escape;
-	    }
-	  } else {
-	    sscanf (message.buffer, "STATUS %d", &status);
-	  }
-
-	  // receive the resulting stderr
-	  if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
-	    switch (errno) {
-	      case EPIPE:
-		gprint (GP_ERR, "server connection has died\n");
-		exit (34);
-	      default:
-		gprint (GP_ERR, "server is busy...34\n");
-		bufferPending = TRUE;
-		goto escape;
-	    }
-	  } else {
-	    gwrite (message.buffer, 1, message.Nbuffer, GP_ERR);
-	  }
-
-	  // receive the resulting stdout
-	  if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
-	    switch (errno) {
-	      case EPIPE:
-		gprint (GP_ERR, "server connection has died\n");
-		exit (35);
-	      default:
-		gprint (GP_ERR, "server is busy...35\n");
-		bufferPending = TRUE;
-		goto escape;
-	    }
-	  } else {
-	    gwrite (message.buffer, 1, message.Nbuffer, GP_LOG);
+	// receive the command exit status
+	if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
+	  switch (errno) {
+	    case EPIPE:
+	      gprint (GP_ERR, "server connection has died\n");
+	      exit (33);
+	    default:
+	      gprint (GP_ERR, "server is busy...33\n");
+	      bufferPending = TRUE;
+	      goto escape;
 	  }
 	} else {
-	  // if no server is defined, we treat an unknown command as an error
-	  status = FALSE;
-	}	
-      }
-    escape:
-      if (outline != NULL) free (outline);
-      if (!status && auto_break) done = TRUE;
+	  sscanf (message.buffer, "STATUS %d", &status);
+	}
+
+	// receive the resulting stderr
+	if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
+	  switch (errno) {
+	    case EPIPE:
+	      gprint (GP_ERR, "server connection has died\n");
+	      exit (34);
+	    default:
+	      gprint (GP_ERR, "server is busy...34\n");
+	      bufferPending = TRUE;
+	      goto escape;
+	  }
+	} else {
+	  gwrite (message.buffer, 1, message.Nbuffer, GP_ERR);
+	}
+
+	// receive the resulting stdout
+	if (ExpectMessage (server, MSG_TIMEOUT, &message)) {
+	  switch (errno) {
+	    case EPIPE:
+	      gprint (GP_ERR, "server connection has died\n");
+	      exit (35);
+	    default:
+	      gprint (GP_ERR, "server is busy...35\n");
+	      bufferPending = TRUE;
+	      goto escape;
+	  }
+	} else {
+	  gwrite (message.buffer, 1, message.Nbuffer, GP_LOG);
+	}
+      } else {
+	// if no server is defined, we treat an unknown command as an error
+	status = FALSE;
+      }	
     }
+  escape:
+    if (outline != NULL) free (outline);
+    if (!status && auto_break) done = TRUE;
+
     p = q + 1;
   }
Index: /trunk/Ohana/src/opihi/lib.shell/startup.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 41160)
+++ /trunk/Ohana/src/opihi/lib.shell/startup.c	(revision 41161)
@@ -107,4 +107,16 @@
       LOAD_RC = FALSE;
     }
+    if ((N = get_argument (*argc, argv, "--no-rc"))) {
+      remove_argument (N, argc, argv);
+      LOAD_RC = FALSE;
+    }
+    if ((N = get_argument (*argc, argv, "-norc"))) {
+      remove_argument (N, argc, argv);
+      LOAD_RC = FALSE;
+    }
+    if ((N = get_argument (*argc, argv, "-no-rc"))) {
+      remove_argument (N, argc, argv);
+      LOAD_RC = FALSE;
+    }
     
     ONLY_INPUT = FALSE;
