Index: trunk/Ohana/src/opihi/lib.shell/command.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/command.c	(revision 27790)
+++ trunk/Ohana/src/opihi/lib.shell/command.c	(revision 30614)
@@ -10,6 +10,8 @@
   Command *cmd;
 
-  // rawline = NULL;
-  rawline = strcreate (line);
+  // the input line is never NULL
+  if (!line) { fprintf (stderr, "programming error\n"); abort(); }
+
+  rawline = strcreate (line);  // used for error messages which should echo the unparsed line
 
   /* force a space between ! and first word: !ls becomes ! ls */
@@ -22,6 +24,9 @@
   /* 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 
@@ -29,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 */
@@ -39,4 +45,5 @@
   if (argc == 0) {
       FREE (rawline);
+      set_int_variable ("STATUS", TRUE);
       return (TRUE);  /* empty command or assignment */
   }
@@ -74,4 +81,19 @@
   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);
+
+  if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline);
+
+  // return the current value of line, in case it was modified
+  *outline = line;
+  return FALSE;
 }
 
