diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
commit | f6bad5ef766b0447158e3de2f55c35f1f6cecb58 (patch) | |
tree | f5ec7ac45234c25794c97f87e9a6daa8a551e57c /shell | |
parent | 72394258b6509b40e0fa08594ac86215a558dfd8 (diff) | |
parent | 8d0e0cdadf726beab28ccdc7d69738c1534e1f74 (diff) | |
download | busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.gz busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.bz2 busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.zip |
Merge commit '8d0e0cdadf726beab28ccdc7d69738c1534e1f74' into merge
Conflicts:
include/platform.h
libbb/Kbuild.src
libbb/messages.c
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 8 | ||||
-rw-r--r-- | shell/cttyhack.c | 2 | ||||
-rw-r--r-- | shell/hush.c | 62 |
3 files changed, 42 insertions, 30 deletions
diff --git a/shell/ash.c b/shell/ash.c index 93c582f73..28f988698 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -86,9 +86,9 @@ | |||
86 | # error "Do not even bother, ash will not run on NOMMU machine" | 86 | # error "Do not even bother, ash will not run on NOMMU machine" |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | //applet:IF_ASH(APPLET(ash, _BB_DIR_BIN, _BB_SUID_DROP)) | 89 | //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) |
90 | //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, _BB_DIR_BIN, _BB_SUID_DROP, sh)) | 90 | //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) |
91 | //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, _BB_DIR_BIN, _BB_SUID_DROP, bash)) | 91 | //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) |
92 | 92 | ||
93 | //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o | 93 | //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o |
94 | //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o | 94 | //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o |
@@ -5195,6 +5195,8 @@ stoppedjobs(void) | |||
5195 | * Code for dealing with input/output redirection. | 5195 | * Code for dealing with input/output redirection. |
5196 | */ | 5196 | */ |
5197 | 5197 | ||
5198 | #undef EMPTY | ||
5199 | #undef CLOSED | ||
5198 | #define EMPTY -2 /* marks an unused slot in redirtab */ | 5200 | #define EMPTY -2 /* marks an unused slot in redirtab */ |
5199 | #define CLOSED -3 /* marks a slot of previously-closed fd */ | 5201 | #define CLOSED -3 /* marks a slot of previously-closed fd */ |
5200 | 5202 | ||
diff --git a/shell/cttyhack.c b/shell/cttyhack.c index d1cb7fcc3..d1ac2cd23 100644 --- a/shell/cttyhack.c +++ b/shell/cttyhack.c | |||
@@ -6,7 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | 8 | ||
9 | //applet:IF_CTTYHACK(APPLET(cttyhack, _BB_DIR_BIN, _BB_SUID_DROP)) | 9 | //applet:IF_CTTYHACK(APPLET(cttyhack, BB_DIR_BIN, BB_SUID_DROP)) |
10 | 10 | ||
11 | //kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o | 11 | //kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o |
12 | 12 | ||
diff --git a/shell/hush.c b/shell/hush.c index a771e9cd9..1709fd9d1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -105,10 +105,10 @@ | |||
105 | # define PIPE_BUF 4096 /* amount of buffering in a pipe */ | 105 | # define PIPE_BUF 4096 /* amount of buffering in a pipe */ |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | //applet:IF_HUSH(APPLET(hush, _BB_DIR_BIN, _BB_SUID_DROP)) | 108 | //applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) |
109 | //applet:IF_MSH(APPLET(msh, _BB_DIR_BIN, _BB_SUID_DROP)) | 109 | //applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) |
110 | //applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, _BB_DIR_BIN, _BB_SUID_DROP, sh)) | 110 | //applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) |
111 | //applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, _BB_DIR_BIN, _BB_SUID_DROP, bash)) | 111 | //applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) |
112 | 112 | ||
113 | //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o | 113 | //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o |
114 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o | 114 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o |
@@ -445,7 +445,6 @@ typedef struct in_str { | |||
445 | char eof_flag; /* meaningless if ->p == NULL */ | 445 | char eof_flag; /* meaningless if ->p == NULL */ |
446 | char peek_buf[2]; | 446 | char peek_buf[2]; |
447 | #if ENABLE_HUSH_INTERACTIVE | 447 | #if ENABLE_HUSH_INTERACTIVE |
448 | smallint promptme; | ||
449 | smallint promptmode; /* 0: PS1, 1: PS2 */ | 448 | smallint promptmode; /* 0: PS1, 1: PS2 */ |
450 | #endif | 449 | #endif |
451 | FILE *file; | 450 | FILE *file; |
@@ -1946,22 +1945,17 @@ static int FAST_FUNC file_get(struct in_str *i) | |||
1946 | /* need to double check i->file because we might be doing something | 1945 | /* need to double check i->file because we might be doing something |
1947 | * more complicated by now, like sourcing or substituting. */ | 1946 | * more complicated by now, like sourcing or substituting. */ |
1948 | #if ENABLE_HUSH_INTERACTIVE | 1947 | #if ENABLE_HUSH_INTERACTIVE |
1949 | if (G_interactive_fd && i->promptme && i->file == stdin) { | 1948 | if (G_interactive_fd && i->file == stdin) { |
1950 | do { | 1949 | do { |
1951 | get_user_input(i); | 1950 | get_user_input(i); |
1952 | } while (!*i->p); /* need non-empty line */ | 1951 | } while (!*i->p); /* need non-empty line */ |
1953 | i->promptmode = 1; /* PS2 */ | 1952 | i->promptmode = 1; /* PS2 */ |
1954 | i->promptme = 0; | ||
1955 | goto take_cached; | 1953 | goto take_cached; |
1956 | } | 1954 | } |
1957 | #endif | 1955 | #endif |
1958 | do ch = fgetc(i->file); while (ch == '\0'); | 1956 | do ch = fgetc(i->file); while (ch == '\0'); |
1959 | } | 1957 | } |
1960 | debug_printf("file_get: got '%c' %d\n", ch, ch); | 1958 | debug_printf("file_get: got '%c' %d\n", ch, ch); |
1961 | #if ENABLE_HUSH_INTERACTIVE | ||
1962 | if (ch == '\n') | ||
1963 | i->promptme = 1; | ||
1964 | #endif | ||
1965 | return ch; | 1959 | return ch; |
1966 | } | 1960 | } |
1967 | 1961 | ||
@@ -1988,26 +1982,22 @@ static int FAST_FUNC file_peek(struct in_str *i) | |||
1988 | 1982 | ||
1989 | static void setup_file_in_str(struct in_str *i, FILE *f) | 1983 | static void setup_file_in_str(struct in_str *i, FILE *f) |
1990 | { | 1984 | { |
1985 | memset(i, 0, sizeof(*i)); | ||
1991 | i->peek = file_peek; | 1986 | i->peek = file_peek; |
1992 | i->get = file_get; | 1987 | i->get = file_get; |
1993 | #if ENABLE_HUSH_INTERACTIVE | 1988 | /* i->promptmode = 0; - PS1 (memset did it) */ |
1994 | i->promptme = 1; | ||
1995 | i->promptmode = 0; /* PS1 */ | ||
1996 | #endif | ||
1997 | i->file = f; | 1989 | i->file = f; |
1998 | i->p = NULL; | 1990 | /* i->p = NULL; */ |
1999 | } | 1991 | } |
2000 | 1992 | ||
2001 | static void setup_string_in_str(struct in_str *i, const char *s) | 1993 | static void setup_string_in_str(struct in_str *i, const char *s) |
2002 | { | 1994 | { |
1995 | memset(i, 0, sizeof(*i)); | ||
2003 | i->peek = static_peek; | 1996 | i->peek = static_peek; |
2004 | i->get = static_get; | 1997 | i->get = static_get; |
2005 | #if ENABLE_HUSH_INTERACTIVE | 1998 | /* i->promptmode = 0; - PS1 (memset did it) */ |
2006 | i->promptme = 1; | ||
2007 | i->promptmode = 0; /* PS1 */ | ||
2008 | #endif | ||
2009 | i->p = s; | 1999 | i->p = s; |
2010 | i->eof_flag = 0; | 2000 | /* i->eof_flag = 0; */ |
2011 | } | 2001 | } |
2012 | 2002 | ||
2013 | 2003 | ||
@@ -4031,9 +4021,6 @@ static struct pipe *parse_stream(char **pstring, | |||
4031 | 4021 | ||
4032 | reset: /* we come back here only on syntax errors in interactive shell */ | 4022 | reset: /* we come back here only on syntax errors in interactive shell */ |
4033 | 4023 | ||
4034 | #if ENABLE_HUSH_INTERACTIVE | ||
4035 | input->promptmode = 0; /* PS1 */ | ||
4036 | #endif | ||
4037 | if (MAYBE_ASSIGNMENT != 0) | 4024 | if (MAYBE_ASSIGNMENT != 0) |
4038 | dest.o_assignment = MAYBE_ASSIGNMENT; | 4025 | dest.o_assignment = MAYBE_ASSIGNMENT; |
4039 | initialize_context(&ctx); | 4026 | initialize_context(&ctx); |
@@ -4140,7 +4127,27 @@ static struct pipe *parse_stream(char **pstring, | |||
4140 | if (IS_NULL_CMD(ctx.command) | 4127 | if (IS_NULL_CMD(ctx.command) |
4141 | && dest.length == 0 && !dest.has_quoted_part | 4128 | && dest.length == 0 && !dest.has_quoted_part |
4142 | ) { | 4129 | ) { |
4143 | continue; | 4130 | /* This newline can be ignored. But... |
4131 | * Without check #1, interactive shell | ||
4132 | * ignores even bare <newline>, | ||
4133 | * and shows the continuation prompt: | ||
4134 | * ps1_prompt$ <enter> | ||
4135 | * ps2> _ <=== wrong, should be ps1 | ||
4136 | * Without check #2, "cmd & <newline>" | ||
4137 | * is similarly mistreated. | ||
4138 | * (BTW, this makes "cmd & cmd" | ||
4139 | * and "cmd && cmd" non-orthogonal. | ||
4140 | * Really, ask yourself, why | ||
4141 | * "cmd && <newline>" doesn't start | ||
4142 | * cmd but waits for more input? | ||
4143 | * No reason...) | ||
4144 | */ | ||
4145 | struct pipe *pi = ctx.list_head; | ||
4146 | if (pi->num_cmds != 0 /* check #1 */ | ||
4147 | && pi->followup != PIPE_BG /* check #2 */ | ||
4148 | ) { | ||
4149 | continue; | ||
4150 | } | ||
4144 | } | 4151 | } |
4145 | /* Treat newline as a command separator. */ | 4152 | /* Treat newline as a command separator. */ |
4146 | done_pipe(&ctx, PIPE_SEQ); | 4153 | done_pipe(&ctx, PIPE_SEQ); |
@@ -4519,7 +4526,6 @@ static struct pipe *parse_stream(char **pstring, | |||
4519 | } | 4526 | } |
4520 | /* Discard cached input, force prompt */ | 4527 | /* Discard cached input, force prompt */ |
4521 | input->p = NULL; | 4528 | input->p = NULL; |
4522 | IF_HUSH_INTERACTIVE(input->promptme = 1;) | ||
4523 | goto reset; | 4529 | goto reset; |
4524 | } | 4530 | } |
4525 | } | 4531 | } |
@@ -5519,6 +5525,10 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) | |||
5519 | while (1) { | 5525 | while (1) { |
5520 | struct pipe *pipe_list; | 5526 | struct pipe *pipe_list; |
5521 | 5527 | ||
5528 | #if ENABLE_HUSH_INTERACTIVE | ||
5529 | if (end_trigger == ';') | ||
5530 | inp->promptmode = 0; /* PS1 */ | ||
5531 | #endif | ||
5522 | pipe_list = parse_stream(NULL, inp, end_trigger); | 5532 | pipe_list = parse_stream(NULL, inp, end_trigger); |
5523 | if (!pipe_list) { /* EOF */ | 5533 | if (!pipe_list) { /* EOF */ |
5524 | if (empty) | 5534 | if (empty) |