summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorEric Andersen2001-05-01 01:49:50 +0000
committerEric Andersen2001-05-01 01:49:50 +0000
commit4ed5e37d4b6569b16758ae736084d96f6f19a0ac (patch)
tree0424bb0d95468696e906f17a5d5232427eb858db /shell
parent3f99b567b8500be6095f4ef36d6733873ebfe0c8 (diff)
downloadbusybox-4ed5e37d4b6569b16758ae736084d96f6f19a0ac.zip
busybox-4ed5e37d4b6569b16758ae736084d96f6f19a0ac.tar.gz
Another hush update from Larry:
Minor improvements. Something is still broken with running scripts via "hush filename". All the following are now handled acceptably (matches ash, not bash). if true; then echo foo1; fi if true; then echo foo2; fi if true; false; then echo bar; else echo foo3; fi if true || false; then echo foo4; fi - Larry
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 4753bd7..8ef1e27 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -102,7 +102,7 @@
#include <signal.h>
/* #include <dmalloc.h> */
-#define DEBUG_SHELL
+/* #define DEBUG_SHELL */
#ifdef BB_VER
#include "busybox.h"
@@ -814,7 +814,12 @@ static int file_get(struct in_str *i)
if (i->__promptme && interactive && i->file == stdin) {
get_user_input(i);
i->promptmode=2;
+ } else {
+ static char buffer;
+ buffer = fgetc(i->file);
+ i->p = &buffer;
}
+
i->__promptme = 0;
if (i->p && *i->p) {
@@ -1152,15 +1157,17 @@ static int run_list_real(struct pipe *pi)
{
int rcode=0;
int if_code=0, next_if_code=0; /* need double-buffer to handle elif */
- reserved_style rmode=RES_NONE;
+ reserved_style rmode, skip_more_in_this_rmode=RES_XXXX;
for (;pi;pi=pi->next) {
rmode = pi->r_mode;
- debug_printf("rmode=%d if_code=%d next_if_code=%d\n", rmode, if_code, next_if_code);
+ debug_printf("rmode=%d if_code=%d next_if_code=%d skip_more=%d\n", rmode, if_code, next_if_code, skip_more_in_this_rmode);
+ if (rmode == skip_more_in_this_rmode) continue;
+ skip_more_in_this_rmode = RES_XXXX;
if (rmode == RES_THEN || rmode == RES_ELSE) if_code = next_if_code;
if (rmode == RES_THEN && if_code) continue;
if (rmode == RES_ELSE && !if_code) continue;
if (rmode == RES_ELIF && !if_code) continue;
- if (pi->num_progs == 0) break;
+ if (pi->num_progs == 0) continue;
rcode = run_pipe_real(pi);
if (rcode!=-1) {
/* We only ran a builtin: rcode was set by the return value
@@ -1194,7 +1201,8 @@ static int run_list_real(struct pipe *pi)
next_if_code=rcode; /* can be overwritten a number of times */
if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) ||
(rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) )
- return rcode; /* XXX broken if list is part of if/then/else */
+ skip_more_in_this_rmode=rmode;
+ /* return rcode; */ /* XXX broken if list is part of if/then/else */
}
return rcode;
}