Index: /trunk/Ohana/src/opihi/cmd.basic/run_while.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 9843)
+++ /trunk/Ohana/src/opihi/cmd.basic/run_while.c	(revision 9844)
@@ -6,5 +6,5 @@
 
   int ThisList, depth, i, done, status, NLINES, j;
-  char *input, *val;
+  char *input, *val, *logic_line;
   int logic, size;
   Macro loop;
@@ -83,5 +83,9 @@
     if (loop_continue) continue;
 
-    val = dvomath (1, &argv[1], &size, 0);
+    logic_line = strcreate (argv[1]);
+    logic_line = expand_vars (logic_line);
+    val = dvomath (1, &logic_line, &size, 0);
+    free (logic_line);
+
     if (val == NULL) return (FALSE);
     logic = atof (val); /* warning: round-off error is a danger */
Index: /trunk/Ohana/src/opihi/lib.shell/expand_vars.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/expand_vars.c	(revision 9843)
+++ /trunk/Ohana/src/opihi/lib.shell/expand_vars.c	(revision 9844)
@@ -11,4 +11,12 @@
   found = FALSE;
   ALLOCATE (newline, char, 1024);  /* WARNING: this limits the length of the input line */
+
+  V0 = thiscomm (line);
+  if (V0 && !strncmp ("while", V0, strlen(V0))) {
+      // special case: don't expand variables in while () statement
+      strcpy (newline, line);
+      free (line);
+      return (newline);
+  }
 
   /* look for form $a$b..$n and expand only the last ones */
