Index: /branches/eam_branches/ipp-20101205/Ohana/src/opihi/include/shell.h
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/opihi/include/shell.h	(revision 30114)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/opihi/include/shell.h	(revision 30115)
@@ -76,5 +76,5 @@
 char         *expand_vars           	PROTO((char *line));
 char         *expand_vectors        	PROTO((char *line));
-char         *parse                 	PROTO((char *line));
+char         *parse                 	PROTO((int *status, char *line));
 char        **parse_commands        	PROTO((char *, int *));
 void          welcome                   PROTO((void));
Index: /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/command.c
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/command.c	(revision 30114)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/command.c	(revision 30115)
@@ -10,5 +10,7 @@
   Command *cmd;
 
-  // rawline = NULL;
+  // the input line is never NULL
+  if (!line) { fprintf (stderr, "programming error\n"); abort(); }
+
   rawline = strcreate (line);
 
@@ -20,10 +22,11 @@
   }
 
- XXX: check for NULL return from expand_* and raise error
-
   /* expand anything of the form $fred or $fred$sam, etc */ 
   line = expand_vars (line);     /* line is freed here, new one allocated */
+  if (!line) goto escape;
+
   /* expand anything of the form fred[N] */ 
   line = expand_vectors (line);  /* line is freed here, new one allocated */
+  if (!line) goto escape;
 
   // print the line with the variables and vectors expanded, but before evaluating 
@@ -31,7 +34,8 @@
   if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line);
 
-  /* solve math expresions, assign variable, if needed */
-  line = parse (line);        /* line is freed here, new one allocated */
-  /* any entry in line of the form {foo} returns value or tmp vector / buffer */
+  /* solve math expresions, assign variable, if needed.  any entry in line of the form {foo}
+   * returns value or tmp vector / buffer */
+  line = parse (&status, line);        /* line is freed here, new one allocated */
+  if (!status) goto escape;
 
   /* we may have reallocated line, return new pointer */
@@ -41,4 +45,5 @@
   if (argc == 0) {
       FREE (rawline);
+      set_int_variable ("STATUS", TRUE);
       return (TRUE);  /* empty command or assignment */
   }
@@ -76,4 +81,14 @@
   FREE (rawline);
   return (status);
+
+ escape:
+  set_int_variable ("STATUS", FALSE);
+
+  # if (DEBUG) 
+  gprint (GP_ERR, "command: %s, status: %d\n", line, FALSE);
+  # endif
+
+  FREE (rawline);
+  return FALSE;
 }
 
Index: /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/parse.c
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/parse.c	(revision 30114)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/parse.c	(revision 30115)
@@ -1,13 +1,15 @@
 # include "opihi.h"
 
-char *parse (char *line) {
+char *parse (int *status, char *line) {
 
   double fval;
   float *fptr;
   char *newline, *N, *L, *val, *B, *V, *V0, *V1, *c1, *c2, *p;
-  int Nx, Ny, Nbytes, status, size, NLINE, isBuffer, inRange;
+  int Nx, Ny, Nbytes, filestatus, size, NLINE, isBuffer, inRange;
   FILE *f;
   Vector *vec;
   Buffer *buf;
+
+  *status = TRUE; 
 
   Ny = 0;
@@ -73,8 +75,8 @@
       Nbytes = fread (val, 1, 1023, f);
       val[Nbytes] = 0;
-      status = pclose (f);
+      filestatus = pclose (f);
       free (B);
 
-      if (status) gprint (GP_ERR, "warning: exit status of command %d\n", status);
+      if (filestatus) gprint (GP_ERR, "warning: exit status of command %d\n", filestatus);
 
       /* convert all but last return to ' '.  drop last return */
@@ -91,12 +93,10 @@
 
     /* simple variable assignment */
-    if (*V1 != '`') {
-      /* dvomath returns a new string, or NULL, with the result of the expression */
-      val = dvomath (1, &V1, &size, 0);
-      if (val == NULL) { 
-	while (OHANA_WHITESPACE (*V1)) V1++;
-	val = strcreate (V1);
-      } 
-    }
+    /* dvomath returns a new string, or NULL, with the result of the expression */
+    val = dvomath (1, &V1, &size, 0);
+    if (val == NULL) { 
+      while (OHANA_WHITESPACE (*V1)) V1++;
+      val = strcreate (V1);
+    } 
     /* both dvomath and command replacement create (char *) val */
     set_str_variable (V0, val);
@@ -172,5 +172,5 @@
       if (!inRange) {
 	gprint (GP_ERR, "no element %d,%d\n", Nx, Ny);
-	goto escape;
+	goto error;
       }
       if (Nx < 0) Nx += buf[0].header.Naxis[0];
@@ -188,5 +188,5 @@
       if (!inRange) {
 	gprint (GP_ERR, "no element %d\n", Nx);
-	goto escape;
+	goto error;
       }
       if (Nx < 0) Nx += vec[0].Nelements;
@@ -197,5 +197,4 @@
       }
     }
-
     goto escape;
   }
@@ -226,10 +225,10 @@
     if (c1 == NULL) {
       gprint (GP_ERR, "no close brackets!\n");
-      goto escape;
+      goto error;
     }
     c2 = strchr (L, '{');
     if ((c2 != NULL) && (c2 < c1)) {
       gprint (GP_ERR, "can't nest brackets!\n");
-      goto escape;
+      goto error;
     }
     *c1 = 0;
@@ -240,5 +239,5 @@
     if (val == NULL) {
       print_error ();
-      goto escape;
+      goto error;
     } 
 
@@ -257,13 +256,22 @@
   
   REALLOCATE (newline, char, strlen (newline) + 1);
+  *status = TRUE;
   return (newline); 
 
 error:
   gprint (GP_ERR, "syntax error\n");
-
-escape:
+  // assignment or increment operation: free line and return NULL
   if (line != (char *) NULL) free (line);
   if (val != (char *) NULL) free (val);
   if (V0 != (char *) NULL) free (V0);
+  *status = FALSE;
+  return NULL;
+
+escape:
+  // assignment or increment operation: free line and return NULL
+  if (line != (char *) NULL) free (line);
+  if (val != (char *) NULL) free (val);
+  if (V0 != (char *) NULL) free (V0);
+  *status = TRUE;
   return (NULL);
 }
