diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-01 01:49:50 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-01 01:49:50 +0000 |
commit | b366264b9c3eead7518bc141f2e29b16dfc03596 (patch) | |
tree | 0424bb0d95468696e906f17a5d5232427eb858db /shell | |
parent | 338f7024096e4edaabc8b4b919274b90f09a0b3c (diff) | |
download | busybox-w32-b366264b9c3eead7518bc141f2e29b16dfc03596.tar.gz busybox-w32-b366264b9c3eead7518bc141f2e29b16dfc03596.tar.bz2 busybox-w32-b366264b9c3eead7518bc141f2e29b16dfc03596.zip |
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
git-svn-id: svn://busybox.net/trunk/busybox@2500 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r-- | shell/hush.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c index 4753bd7ab..8ef1e2731 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -102,7 +102,7 @@ | |||
102 | #include <signal.h> | 102 | #include <signal.h> |
103 | 103 | ||
104 | /* #include <dmalloc.h> */ | 104 | /* #include <dmalloc.h> */ |
105 | #define DEBUG_SHELL | 105 | /* #define DEBUG_SHELL */ |
106 | 106 | ||
107 | #ifdef BB_VER | 107 | #ifdef BB_VER |
108 | #include "busybox.h" | 108 | #include "busybox.h" |
@@ -814,7 +814,12 @@ static int file_get(struct in_str *i) | |||
814 | if (i->__promptme && interactive && i->file == stdin) { | 814 | if (i->__promptme && interactive && i->file == stdin) { |
815 | get_user_input(i); | 815 | get_user_input(i); |
816 | i->promptmode=2; | 816 | i->promptmode=2; |
817 | } else { | ||
818 | static char buffer; | ||
819 | buffer = fgetc(i->file); | ||
820 | i->p = &buffer; | ||
817 | } | 821 | } |
822 | |||
818 | i->__promptme = 0; | 823 | i->__promptme = 0; |
819 | 824 | ||
820 | if (i->p && *i->p) { | 825 | if (i->p && *i->p) { |
@@ -1152,15 +1157,17 @@ static int run_list_real(struct pipe *pi) | |||
1152 | { | 1157 | { |
1153 | int rcode=0; | 1158 | int rcode=0; |
1154 | int if_code=0, next_if_code=0; /* need double-buffer to handle elif */ | 1159 | int if_code=0, next_if_code=0; /* need double-buffer to handle elif */ |
1155 | reserved_style rmode=RES_NONE; | 1160 | reserved_style rmode, skip_more_in_this_rmode=RES_XXXX; |
1156 | for (;pi;pi=pi->next) { | 1161 | for (;pi;pi=pi->next) { |
1157 | rmode = pi->r_mode; | 1162 | rmode = pi->r_mode; |
1158 | debug_printf("rmode=%d if_code=%d next_if_code=%d\n", rmode, if_code, next_if_code); | 1163 | 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); |
1164 | if (rmode == skip_more_in_this_rmode) continue; | ||
1165 | skip_more_in_this_rmode = RES_XXXX; | ||
1159 | if (rmode == RES_THEN || rmode == RES_ELSE) if_code = next_if_code; | 1166 | if (rmode == RES_THEN || rmode == RES_ELSE) if_code = next_if_code; |
1160 | if (rmode == RES_THEN && if_code) continue; | 1167 | if (rmode == RES_THEN && if_code) continue; |
1161 | if (rmode == RES_ELSE && !if_code) continue; | 1168 | if (rmode == RES_ELSE && !if_code) continue; |
1162 | if (rmode == RES_ELIF && !if_code) continue; | 1169 | if (rmode == RES_ELIF && !if_code) continue; |
1163 | if (pi->num_progs == 0) break; | 1170 | if (pi->num_progs == 0) continue; |
1164 | rcode = run_pipe_real(pi); | 1171 | rcode = run_pipe_real(pi); |
1165 | if (rcode!=-1) { | 1172 | if (rcode!=-1) { |
1166 | /* We only ran a builtin: rcode was set by the return value | 1173 | /* We only ran a builtin: rcode was set by the return value |
@@ -1194,7 +1201,8 @@ static int run_list_real(struct pipe *pi) | |||
1194 | next_if_code=rcode; /* can be overwritten a number of times */ | 1201 | next_if_code=rcode; /* can be overwritten a number of times */ |
1195 | if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) || | 1202 | if ( (rcode==EXIT_SUCCESS && pi->followup==PIPE_OR) || |
1196 | (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) ) | 1203 | (rcode!=EXIT_SUCCESS && pi->followup==PIPE_AND) ) |
1197 | return rcode; /* XXX broken if list is part of if/then/else */ | 1204 | skip_more_in_this_rmode=rmode; |
1205 | /* return rcode; */ /* XXX broken if list is part of if/then/else */ | ||
1198 | } | 1206 | } |
1199 | return rcode; | 1207 | return rcode; |
1200 | } | 1208 | } |