diff -ur esh-20110121/esh/src/esh.c esh-20110929/esh/src/esh.c --- esh-20110121/esh/src/esh.c 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/esh.c 2011-09-29 11:41:37.000000000 -0400 @@ -99,9 +99,14 @@ struct esh_command_line * cline = shell.parse_command_line(cmdline); free (cmdline); - if (list_empty(&cline->pipes)) /* User hit enter */ + if (cline == NULL) /* Error in command line */ continue; + if (list_empty(&cline->pipes)) { /* User hit enter */ + esh_command_line_free(cline); + continue; + } + esh_command_line_print(cline); esh_command_line_free(cline); } diff -ur esh-20110121/esh/src/esh-grammar.y esh-20110929/esh/src/esh-grammar.y --- esh-20110121/esh/src/esh-grammar.y 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/esh-grammar.y 2011-09-29 11:41:37.000000000 -0400 @@ -6,6 +6,8 @@ * * This is based on an assignment I did in 1993 as an undergraduate * student at Technische Universitaet Berlin. + * + * Known bugs: leaks memory when parse errors occur. */ %{ #include @@ -167,12 +169,14 @@ obstack_ptr_grow(&$$.words, $2); } | command input { + obstack_free(&$2.words, NULL); /* Error: ambiguous redirect 'a b >c' */ if ($1.iored_output) { p_error(AMBOUT); YYABORT; } $$ = $1; diff -ur esh-20110121/esh/src/esh.h esh-20110929/esh/src/esh.h --- esh-20110121/esh/src/esh.h 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/esh.h 2011-09-29 11:41:37.000000000 -0400 @@ -4,7 +4,7 @@ * Developed by Godmar Back for CS 3214 Fall 2009 * Virginia Tech. * - * $Id: esh.h,v 1.6 2011/01/21 20:11:26 cs3214 Exp $ + * $Id: esh.h,v 1.7 2011/09/29 15:39:20 cs3214 Exp $ */ #include @@ -63,8 +63,10 @@ /* Initialize plugin and pass shell object */ bool (* init)(struct esh_shell *); - /* A plugin may return false for each following functions - * to indicate that processing should stop. + /* The return value of the following three functions indicates + * whether the plugin wants processing to stop. + * true - indicates processing should stop. + * false - indicates processing should continue. */ /* The command line the user entered. * A plugin may change it. */ diff -ur esh-20110121/esh/src/eshoutput.py esh-20110929/esh/src/eshoutput.py --- esh-20110121/esh/src/eshoutput.py 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/eshoutput.py 2011-09-29 11:41:37.000000000 -0400 @@ -36,6 +36,9 @@ # # builtin commands # +# Use printf-style formats. stop, kill, fg, and bg expect job ids. +# If your shell requires a % before the jobid, use %%%s. +# builtin_commands = { 'jobs' : 'jobs', 'stop' : 'stop %s', @@ -43,6 +46,3 @@ 'fg' : 'fg %s', 'bg' : 'bg %s' } - -# logfile = open("/dev/tty", "w") - diff -ur esh-20110121/esh/src/esh-sys-utils.c esh-20110929/esh/src/esh-sys-utils.c --- esh-20110121/esh/src/esh-sys-utils.c 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/esh-sys-utils.c 2011-09-29 11:41:37.000000000 -0400 @@ -20,7 +20,7 @@ #include "esh-sys-utils.h" -static const char rcsid [] = "$Id: esh-sys-utils.c,v 1.4 2011/01/21 20:11:26 cs3214 Exp $"; +static const char rcsid [] = "$Id: esh-sys-utils.c,v 1.5 2011/09/29 15:39:20 cs3214 Exp $"; /* Utility function for esh_sys_fatal_error and esh_sys_error */ static void @@ -151,7 +151,7 @@ * signal handler is entered. */ .sa_mask = emptymask, /* restart system calls when possible */ - .sa_flags = SA_RESTART + .sa_flags = SA_RESTART | SA_SIGINFO }; if (sigaction(sig, &sa, NULL) != 0) diff -ur esh-20110121/esh/src/esh-utils.c esh-20110929/esh/src/esh-utils.c --- esh-20110121/esh/src/esh-utils.c 2011-01-21 15:17:02.000000000 -0500 +++ esh-20110929/esh/src/esh-utils.c 2011-09-29 11:41:37.000000000 -0400 @@ -13,7 +13,7 @@ #include "esh.h" -static const char rcsid [] = "$Id: esh-utils.c,v 1.5 2011/01/21 20:11:26 cs3214 Exp $"; +static const char rcsid [] = "$Id: esh-utils.c,v 1.6 2011/09/29 15:39:20 cs3214 Exp $"; /* List of loaded plugins */ struct list esh_plugin_list; @@ -176,6 +176,10 @@ while (*p) { free(*p++); } + if (cmd->iored_input) + free(cmd->iored_input); + if (cmd->iored_output) + free(cmd->iored_output); free(cmd->argv); free(cmd); }