diff options
author | Ron Yorston <rmy@pobox.com> | 2015-03-14 20:33:00 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-03-14 20:33:00 +0000 |
commit | a4f58436b78fe59e57620c6e0301f213ee25f273 (patch) | |
tree | 8355f724926e605280af2d6f2b1ccc6b1bd02dee /shell | |
parent | ba0c36cfcf84efbac6f89e27238e04bb57e9cd45 (diff) | |
parent | 49acc1a7618a28d34381cbb7661d7c981fcb238f (diff) | |
download | busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.tar.gz busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.tar.bz2 busybox-w32-a4f58436b78fe59e57620c6e0301f213ee25f273.zip |
Merge branch 'busybox' into merge
Conflicts:
coreutils/od_bloaty.c
libbb/lineedit.c
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 33 | ||||
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc1.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc1.tests | 3 | ||||
-rw-r--r-- | shell/hush.c | 2 |
4 files changed, 25 insertions, 14 deletions
diff --git a/shell/ash.c b/shell/ash.c index b95356034..df7083370 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7075,6 +7075,14 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list) | |||
7075 | len = strlen(p); | 7075 | len = strlen(p); |
7076 | if (!(subtype == VSPLUS || subtype == VSLENGTH)) | 7076 | if (!(subtype == VSPLUS || subtype == VSLENGTH)) |
7077 | memtodest(p, len, syntax, quotes); | 7077 | memtodest(p, len, syntax, quotes); |
7078 | #if ENABLE_UNICODE_SUPPORT | ||
7079 | if (subtype == VSLENGTH && len > 0) { | ||
7080 | reinit_unicode_for_ash(); | ||
7081 | if (unicode_status == UNICODE_ON) { | ||
7082 | len = unicode_strlen(p); | ||
7083 | } | ||
7084 | } | ||
7085 | #endif | ||
7078 | return len; | 7086 | return len; |
7079 | } | 7087 | } |
7080 | 7088 | ||
@@ -7158,15 +7166,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list) | |||
7158 | varunset(p, var, 0, 0); | 7166 | varunset(p, var, 0, 0); |
7159 | 7167 | ||
7160 | if (subtype == VSLENGTH) { | 7168 | if (subtype == VSLENGTH) { |
7161 | ssize_t n = varlen; | 7169 | cvtnum(varlen > 0 ? varlen : 0); |
7162 | if (n > 0) { | ||
7163 | reinit_unicode_for_ash(); | ||
7164 | if (unicode_status == UNICODE_ON) { | ||
7165 | const char *val = lookupvar(var); | ||
7166 | n = unicode_strlen(val); | ||
7167 | } | ||
7168 | } | ||
7169 | cvtnum(n > 0 ? n : 0); | ||
7170 | goto record; | 7170 | goto record; |
7171 | } | 7171 | } |
7172 | 7172 | ||
@@ -10981,7 +10981,7 @@ static union node *andor(void); | |||
10981 | static union node *pipeline(void); | 10981 | static union node *pipeline(void); |
10982 | static union node *parse_command(void); | 10982 | static union node *parse_command(void); |
10983 | static void parseheredoc(void); | 10983 | static void parseheredoc(void); |
10984 | static char peektoken(void); | 10984 | static char nexttoken_ends_list(void); |
10985 | static int readtoken(void); | 10985 | static int readtoken(void); |
10986 | 10986 | ||
10987 | static union node * | 10987 | static union node * |
@@ -10991,7 +10991,7 @@ list(int nlflag) | |||
10991 | int tok; | 10991 | int tok; |
10992 | 10992 | ||
10993 | checkkwd = CHKNL | CHKKWD | CHKALIAS; | 10993 | checkkwd = CHKNL | CHKKWD | CHKALIAS; |
10994 | if (nlflag == 2 && peektoken()) | 10994 | if (nlflag == 2 && nexttoken_ends_list()) |
10995 | return NULL; | 10995 | return NULL; |
10996 | n1 = NULL; | 10996 | n1 = NULL; |
10997 | for (;;) { | 10997 | for (;;) { |
@@ -11033,8 +11033,15 @@ list(int nlflag) | |||
11033 | tokpushback = 1; | 11033 | tokpushback = 1; |
11034 | } | 11034 | } |
11035 | checkkwd = CHKNL | CHKKWD | CHKALIAS; | 11035 | checkkwd = CHKNL | CHKKWD | CHKALIAS; |
11036 | if (peektoken()) | 11036 | if (nexttoken_ends_list()) { |
11037 | /* Testcase: "<<EOF; then <W". | ||
11038 | * It used to segfault w/o this check: | ||
11039 | */ | ||
11040 | if (heredoclist) { | ||
11041 | raise_error_unexpected_syntax(-1); | ||
11042 | } | ||
11037 | return n1; | 11043 | return n1; |
11044 | } | ||
11038 | break; | 11045 | break; |
11039 | case TEOF: | 11046 | case TEOF: |
11040 | if (heredoclist) | 11047 | if (heredoclist) |
@@ -12471,7 +12478,7 @@ readtoken(void) | |||
12471 | } | 12478 | } |
12472 | 12479 | ||
12473 | static char | 12480 | static char |
12474 | peektoken(void) | 12481 | nexttoken_ends_list(void) |
12475 | { | 12482 | { |
12476 | int t; | 12483 | int t; |
12477 | 12484 | ||
diff --git a/shell/ash_test/ash-heredoc/heredoc1.right b/shell/ash_test/ash-heredoc/heredoc1.right new file mode 100644 index 000000000..895f5ee80 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc1.right | |||
@@ -0,0 +1 @@ | |||
heredoc1.tests: line 3: syntax error: unexpected "then" | |||
diff --git a/shell/ash_test/ash-heredoc/heredoc1.tests b/shell/ash_test/ash-heredoc/heredoc1.tests new file mode 100755 index 000000000..a912a67c7 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc1.tests | |||
@@ -0,0 +1,3 @@ | |||
1 | # We used to SEGV on this: | ||
2 | |||
3 | <<EOF; then <W | ||
diff --git a/shell/hush.c b/shell/hush.c index 92d790180..f2c0a70f2 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -5884,7 +5884,7 @@ static FILE *generate_stream_from_string(const char *s, pid_t *pid_p) | |||
5884 | * Our solution: ONLY bare $(trap) or `trap` is special. | 5884 | * Our solution: ONLY bare $(trap) or `trap` is special. |
5885 | */ | 5885 | */ |
5886 | s = skip_whitespace(s); | 5886 | s = skip_whitespace(s); |
5887 | if (strncmp(s, "trap", 4) == 0 | 5887 | if (is_prefixed_with(s, "trap") |
5888 | && skip_whitespace(s + 4)[0] == '\0' | 5888 | && skip_whitespace(s + 4)[0] == '\0' |
5889 | ) { | 5889 | ) { |
5890 | static const char *const argv[] = { NULL, NULL }; | 5890 | static const char *const argv[] = { NULL, NULL }; |