--- lab1.old/cmdline.c	Thu Apr  7 18:21:23 2005
+++ lab1/cmdline.c	Thu Apr 21 10:58:22 2005
@@ -221,8 +221,9 @@
 		assert(0);
 	}
 
-	// controlop should be END iff next is NULL
-	assert((cmd->controlop == END) == (cmd->next == NULL));
+	// lines may only end with the END or BACKGROUND controlop
+	assert((cmd->controlop == END) == (cmd->next == NULL) ||
+               (cmd->controlop == BACKGROUND) == (cmd->next == NULL));
 
 	// Print redirections
 	if (cmd->redirect_stdin)
@@ -243,7 +244,7 @@
 		
 	
 
-
+#if 0
 /* 
  * Main function for testing commandline parsing.
  */
@@ -279,3 +280,4 @@
 
 	return 0;
 }
+#endif
--- lab1.old/sh.c	Fri Apr 15 22:59:42 2005
+++ lab1/sh.c	Thu Apr 21 10:52:23 2005
@@ -24,7 +24,7 @@
 main(int argc, char *argv[])
 {
     // String used to store the shell input
-    command_t *cmd;
+    command_t *cmd,*original_cmd;
     char input[BUFSIZ];
     pid_t pid;
     int rc;
@@ -34,7 +34,6 @@
     (void) argc, (void) argv;
     
     while (1) {
-prompt:
         // Print the prompt
         fprintf(stderr, "cs111_spring05$ ");
         
@@ -49,6 +48,8 @@
         
         // build the command list
         cmd = command_parse(input);
+	// save the first command
+	original_cmd = cmd;
         command_print(cmd);
         
         // initialize the pipe file descriptors and rc
@@ -67,7 +68,7 @@
                     /* EXERCISE: wait for the process with 'pid' to exit,
                      * ignore the return code, and prompt for more input
                      */
-                    goto prompt;
+                    goto done;
                 case SEMICOLON: 
                     /* EXERCISE: wait for the process with 'pid' to exit,
                      * but ignore the return code */
@@ -98,8 +99,11 @@
                     assert(0);
             }
         }
+        
+done:  /*You may need this for some of the exercises*/
+            
+	command_free(original_cmd); 
     }
-    
     return 0;
 }
 

