Index: trunk/Ohana/src/opihi/cmd.basic/output.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/output.c	(revision 7917)
+++ trunk/Ohana/src/opihi/cmd.basic/output.c	(revision 7938)
@@ -5,7 +5,8 @@
 int output (int argc, char **argv) {
   
-  int N;
+  int N, Noutput;
   gpDest dest;
   IOBuffer *buffer;
+  char *output;
 
   dest = GP_LOG;
@@ -21,15 +22,25 @@
   }
     
+  /* set the output target and dump the current buffer there */
   if ((N = get_argument (argc, argv, "-dump"))) {
+    buffer = gprintGetBuffer (dest);
+
+    /* save the current buffer contents */
+    Noutput = buffer[0].Nbuffer;
+    ALLOCATE (output, char, Noutput);
+    memcpy (output, buffer[0].buffer, Noutput);
+    
+    /* set the output target to the specified name */
     remove_argument (N, &argc, argv);
-    buffer = gprintGetBuffer (dest);
-    fprintf (STDERR, "buffer contents: \n");
-    fwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, stderr);
-    fprintf (STDERR, "\n");
+    gprintSetFile (dest, argv[N]);
+    remove_argument (N, &argc, argv);
+
+    /* send the output to the appropriate destination */
+    gwrite (output, 1, Noutput, dest);
     return (TRUE);
   }
     
   if (argc != 2) {
-    gprint (GP_ERR, "USAGE: output <filename>\n");
+    gprint (GP_ERR, "USAGE: output <filename> [-err] [-buffer] [-dump filename]\n");
     return (FALSE);
   }
@@ -46,6 +57,2 @@
   outfile = stdout;
 }
-
-/* we could add the concept of saving the output to a buffer
-   then dumping to the target of the output stream.  not sure
-   what the command should look like... */
