Index: /trunk/Ohana/src/opihi/cmd.basic/continue.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/continue.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/cmd.basic/continue.c	(revision 10846)
@@ -1,7 +1,12 @@
 # include "basic.h"
 
-int exec_continue (int argc, char **argv) {
-  loop_continue = TRUE;
+int exec_next (int argc, char **argv) {
+  loop_next = TRUE;
   return (TRUE);
 }
 
+int exec_last (int argc, char **argv) {
+  loop_last = TRUE;
+  return (TRUE);
+}
+
Index: /trunk/Ohana/src/opihi/cmd.basic/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 10846)
@@ -7,6 +7,7 @@
 int date            PROTO((int, char **));
 int echo            PROTO((int, char **));
+int exec_last       PROTO((int, char **));
+int exec_next       PROTO((int, char **));
 int exec_break      PROTO((int, char **));
-int exec_continue   PROTO((int, char **));
 int file            PROTO((int, char **));
 int getchr_func     PROTO((int, char **));
@@ -44,5 +45,8 @@
   {"echo",    	    echo,               "type this line *"},
   {"break",   	    exec_break,         "escape from function *"},
-  {"continue",	    exec_continue,      "next loop iteration"},
+  {"continue",	    exec_next,          "next loop iteration"},
+  {"next",	    exec_next,          "next loop iteration"},
+  {"last",	    exec_last,          "last loop iteration"},
+  {"return",	    exec_last,          "exit from macro"},
   {"file",          file,               "test file existence"},
   {"getchr",        getchr_func,        "find character in string"},
Index: /trunk/Ohana/src/opihi/cmd.basic/run_for.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/cmd.basic/run_for.c	(revision 10846)
@@ -79,7 +79,6 @@
 
   status = TRUE;
-  interrupt = loop_break = FALSE;
+  interrupt = FALSE;
   for (value = start; (sign*value < sign*end) && !interrupt; value += delta) {
-    loop_continue = loop_break = FALSE;
     if ((int)value == value) 
       set_int_variable (argv[1], (int) value);
@@ -88,8 +87,10 @@
     status = exec_loop (&loop);
     value = get_double_variable (argv[1]);
+    if (loop_next) continue;
+    if (loop_last) break;
     if (loop_break) break;
-    if (loop_continue) continue;
   }
-  loop_continue = loop_break = FALSE;
+  loop_last = loop_next = FALSE; 
+  /* 'last' and 'next' should only affect one loop */
   if (auto_break && !status) loop_break = TRUE;
 
@@ -99,4 +100,5 @@
   }
   free (loop.line);
+
   if (loop_break) return (FALSE);
   return (TRUE);
@@ -109,2 +111,12 @@
 */
      
+/* while processing the loop, the loop status variables may be set
+   by the loop commands, or the loop may quite on a failed command,
+   setting the exec_loop return status to false. the loop status variables
+   are:
+   loop_next : stop this loop, but try another loop
+   loop_last : stop loop processing, but return true so external loop may continue
+   loop_break : stop loop processing, and return false so external loop will break
+   interrupt : external interrupt signal
+*/
+
Index: /trunk/Ohana/src/opihi/cmd.basic/run_if.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/run_if.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/cmd.basic/run_if.c	(revision 10846)
@@ -4,27 +4,19 @@
 int run_if (int argc, char **argv) {
 
-  int ThisList, depth, done, status, BreakOnTrue;
-  int logic;
-  char *input, *val;
+  int ThisList, depth, done, status, InlineCommand;
+  int i, length, logic;
+  char *input, *val, *line;
   int nloop, size;
 
-  BreakOnTrue = FALSE;
+  InlineCommand = FALSE;
 
-  if ((argc != 2) && (argc != 3)) {
-    gprint (GP_ERR, "USAGE: if (conditional) [break], end with the word 'END'\n");
+  if (argc < 2) {
+    gprint (GP_ERR, "USAGE: if (conditional) : follow with commands, end with the word 'END'\n");
+    gprint (GP_ERR, "   OR: if (conditional) command\n");
     return (FALSE);
   }
-  if ((argc == 3) && strcmp (argv[2], "break")) {
-    gprint (GP_ERR, "USAGE: if (conditional) [break], end with the word 'END'\n");
-    return (FALSE);
+  if (argc > 2) {
+    InlineCommand = TRUE;
   }
-  if ((argc == 3) && !strcmp (argv[2], "break")) {
-    BreakOnTrue = TRUE;
-  }
-
-  /* read in if-list */
-  nloop = 0;
-  depth = 0;
-  ThisList = current_list_depth();
 
   /* determine value of conditional expression */
@@ -34,15 +26,37 @@
     return (FALSE);
   }
-  logic = atof (val); /* warning: round-off error is a danger */ 
+  logic = atof (val); /* is round-off error a danger? */ 
   free (val);
 
-  if (BreakOnTrue) {
+  if (InlineCommand) {
     if (logic) {
-      loop_break = TRUE;
-      return (FALSE);
+      /* re-build a command line from the remaining strings */
+      length = 0;
+      for (i = 2; i < argc; i++) {
+	length += strlen(argv[i]) + 1;
+      }
+      length++;
+      ALLOCATE (line, char, length);
+      memset (line, 0, length);
+      for (i = 2; i < argc; i++) {
+	if (i == 2) {
+	  strcpy (line, argv[i]);
+	} else {
+	  strcat (line, " ");
+	  strcat (line, argv[i]);
+	}
+      }
+      status = multicommand (line);
+      free (line);
+      return (status);
     } else {
       return (TRUE);
     }
   }    
+
+  /* read in if-list */
+  nloop = 0;
+  depth = 0;
+  ThisList = current_list_depth();
 
   done = FALSE;
Index: /trunk/Ohana/src/opihi/cmd.basic/run_while.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 10846)
@@ -78,8 +78,8 @@
   /* execute for loop */
   do { 
-    loop_continue = loop_break = FALSE;
     status = exec_loop (&loop);
+    if (loop_next) continue;
+    if (loop_last) break;
     if (loop_break) break;
-    if (loop_continue) continue;
 
     logic_line = strcreate (argv[1]);
@@ -92,5 +92,6 @@
     free (val);
   } while (logic && !interrupt);
-  loop_continue = loop_break = FALSE;
+  loop_last = loop_next = FALSE; 
+  /* 'last' and 'next' should only affect one loop */
   if (auto_break && !status) loop_break = TRUE;
 
@@ -100,4 +101,5 @@
   }
   free (loop.line);
+
   if (loop_break) return (FALSE);
   return (TRUE);
Index: /trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- /trunk/Ohana/src/opihi/include/shell.h	(revision 10845)
+++ /trunk/Ohana/src/opihi/include/shell.h	(revision 10846)
@@ -53,6 +53,7 @@
 int 	     interrupt;			/* true if C-C has been pressed */
 int 	     auto_break;		/* if true, zero exit status forces macros to escape */
+int 	     loop_next; 		/* set to true when next (or continue) is called */
+int 	     loop_last; 		/* set to true when last (or return) is called */
 int 	     loop_break;		/* set to true when break is called */
-int 	     loop_continue;		/* set to true when continue is called */
 int          is_script;                 /* being run within a shell script */
 
@@ -150,4 +151,5 @@
 void          gprintSetFile   		PROTO((gpDest dest, char *filename));
 FILE         *gprintGetFile   		PROTO((gpDest dest));
+char         *gprintGetName   		PROTO((gpDest dest));
 int           gprint          		PROTO((gpDest dest, char *format, ...));
 int           gwrite          		PROTO((char *buffer, int size, int N, gpDest dest));
Index: /trunk/Ohana/src/opihi/lib.shell/ListOps.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/ListOps.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/lib.shell/ListOps.c	(revision 10846)
@@ -150,6 +150,6 @@
   if (strcmp (comm, "if")) goto escape;
 
-  /* if (cond) break does not define a complete block */
-  if ((temp != NULL) && !strcmp (temp, "break")) goto escape;
+  /* if (cond) (command) does not define a complete block */
+  if (temp != NULL) goto escape;
 
   if (temp != NULL) free (temp);
Index: /trunk/Ohana/src/opihi/lib.shell/exec_loop.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/exec_loop.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/lib.shell/exec_loop.c	(revision 10846)
@@ -21,5 +21,5 @@
 
   /* process the list */
-  loop_continue = loop_break = FALSE;
+  loop_next = loop_break = loop_last = FALSE;
   status = TRUE;
 
@@ -30,5 +30,5 @@
     free (line);
     if (auto_break && !status) loop_break = TRUE;
-    if (loop_break || loop_continue) break;
+    if (loop_break || loop_last || loop_next) break;
   }
   signal (SIGINT, Signal);
@@ -43,4 +43,2 @@
 
 /** note that the list number runs from 1 - Nlists+1 **/
-/** XXX this is kind of silly: I should simply define a function 
-    to pop next line off the specified list.  review this... **/
Index: /trunk/Ohana/src/opihi/lib.shell/macro_exec.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/macro_exec.c	(revision 10845)
+++ /trunk/Ohana/src/opihi/lib.shell/macro_exec.c	(revision 10846)
@@ -32,4 +32,6 @@
   /* process this list */
   status = exec_loop (&macro[0]);
+  loop_last = loop_next = FALSE; 
+  /* 'last' and 'next' should only affect one loop */
 
   /* clear out the command line variables */
