diff options
author | Ron Yorston <rmy@pobox.com> | 2022-10-12 10:43:26 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-10-12 10:43:26 +0100 |
commit | 49c6f079acb4edae84b4496bd941cdbb5048ba01 (patch) | |
tree | ac54ecaad45050f7bfe274a11db29882aa32a9a8 /shell | |
parent | a55cf07365ec2ff51749a77e09ae9edac79a99fe (diff) | |
parent | c8c1fcdba163f264a503380bc63485aacd09214c (diff) | |
download | busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.tar.gz busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.tar.bz2 busybox-w32-49c6f079acb4edae84b4496bd941cdbb5048ba01.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 26 | ||||
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc_and_cmd.right | 2 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc_and_cmd.tests | 8 | ||||
-rw-r--r-- | shell/hush_test/hush-heredoc/heredoc_and_cmd.right | 2 | ||||
-rwxr-xr-x | shell/hush_test/hush-heredoc/heredoc_and_cmd.tests | 8 |
5 files changed, 44 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index 28c7fe2db..8497538b1 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -149,6 +149,11 @@ | |||
149 | //config: default y | 149 | //config: default y |
150 | //config: depends on SHELL_ASH | 150 | //config: depends on SHELL_ASH |
151 | //config: | 151 | //config: |
152 | //config:config ASH_SLEEP | ||
153 | //config: bool "sleep builtin" | ||
154 | //config: default y | ||
155 | //config: depends on SHELL_ASH | ||
156 | //config: | ||
152 | //config:config ASH_HELP | 157 | //config:config ASH_HELP |
153 | //config: bool "help builtin" | 158 | //config: bool "help builtin" |
154 | //config: default y | 159 | //config: default y |
@@ -7702,6 +7707,7 @@ varunset(const char *end, const char *var, const char *umsg, int varflags) | |||
7702 | msg = umsg; | 7707 | msg = umsg; |
7703 | } | 7708 | } |
7704 | } | 7709 | } |
7710 | ifsfree(); | ||
7705 | ash_msg_and_raise_error("%.*s: %s%s", (int)(end - var - 1), var, msg, tail); | 7711 | ash_msg_and_raise_error("%.*s: %s%s", (int)(end - var - 1), var, msg, tail); |
7706 | } | 7712 | } |
7707 | 7713 | ||
@@ -7997,13 +8003,15 @@ subevalvar(char *start, char *str, int strloc, | |||
7997 | if (idx >= end) | 8003 | if (idx >= end) |
7998 | break; | 8004 | break; |
7999 | STPUTC(*idx, expdest); | 8005 | STPUTC(*idx, expdest); |
8006 | if (stackblock() != restart_detect) | ||
8007 | goto restart; | ||
8000 | if (quotes && (unsigned char)*idx == CTLESC) { | 8008 | if (quotes && (unsigned char)*idx == CTLESC) { |
8001 | idx++; | 8009 | idx++; |
8002 | len++; | 8010 | len++; |
8003 | STPUTC(*idx, expdest); | 8011 | STPUTC(*idx, expdest); |
8012 | if (stackblock() != restart_detect) | ||
8013 | goto restart; | ||
8004 | } | 8014 | } |
8005 | if (stackblock() != restart_detect) | ||
8006 | goto restart; | ||
8007 | idx++; | 8015 | idx++; |
8008 | len++; | 8016 | len++; |
8009 | rmesc++; | 8017 | rmesc++; |
@@ -8028,6 +8036,13 @@ subevalvar(char *start, char *str, int strloc, | |||
8028 | idx = loc; | 8036 | idx = loc; |
8029 | } | 8037 | } |
8030 | 8038 | ||
8039 | /* The STPUTC invocations above may resize and move the | ||
8040 | * stack via realloc(3). Since repl is a pointer into the | ||
8041 | * stack, we need to reconstruct it relative to stackblock(). | ||
8042 | */ | ||
8043 | if (slash_pos >= 0) | ||
8044 | repl = (char *)stackblock() + strloc + slash_pos + 1; | ||
8045 | |||
8031 | //bb_error_msg("repl:'%s'", repl); | 8046 | //bb_error_msg("repl:'%s'", repl); |
8032 | for (loc = (char*)repl; *loc; loc++) { | 8047 | for (loc = (char*)repl; *loc; loc++) { |
8033 | char *restart_detect = stackblock(); | 8048 | char *restart_detect = stackblock(); |
@@ -8127,6 +8142,7 @@ varvalue(char *name, int varflags, int flags, int quoted) | |||
8127 | if (discard) | 8142 | if (discard) |
8128 | return -1; | 8143 | return -1; |
8129 | 8144 | ||
8145 | ifsfree(); | ||
8130 | raise_error_syntax("bad substitution"); | 8146 | raise_error_syntax("bad substitution"); |
8131 | } | 8147 | } |
8132 | 8148 | ||
@@ -11039,6 +11055,9 @@ static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc, | |||
11039 | #if ENABLE_ASH_TEST || BASH_TEST2 | 11055 | #if ENABLE_ASH_TEST || BASH_TEST2 |
11040 | static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } | 11056 | static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); } |
11041 | #endif | 11057 | #endif |
11058 | #if ENABLE_ASH_SLEEP | ||
11059 | static int FAST_FUNC sleepcmd(int argc, char **argv) { return sleep_main(argc, argv); } | ||
11060 | #endif | ||
11042 | 11061 | ||
11043 | /* Keep these in proper order since it is searched via bsearch() */ | 11062 | /* Keep these in proper order since it is searched via bsearch() */ |
11044 | static const struct builtincmd builtintab[] = { | 11063 | static const struct builtincmd builtintab[] = { |
@@ -11101,6 +11120,9 @@ static const struct builtincmd builtintab[] = { | |||
11101 | { BUILTIN_SPEC_REG "return" , returncmd }, | 11120 | { BUILTIN_SPEC_REG "return" , returncmd }, |
11102 | { BUILTIN_SPEC_REG "set" , setcmd }, | 11121 | { BUILTIN_SPEC_REG "set" , setcmd }, |
11103 | { BUILTIN_SPEC_REG "shift" , shiftcmd }, | 11122 | { BUILTIN_SPEC_REG "shift" , shiftcmd }, |
11123 | #if ENABLE_ASH_SLEEP | ||
11124 | { BUILTIN_REGULAR "sleep" , sleepcmd }, | ||
11125 | #endif | ||
11104 | #if BASH_SOURCE | 11126 | #if BASH_SOURCE |
11105 | { BUILTIN_SPEC_REG "source" , dotcmd }, | 11127 | { BUILTIN_SPEC_REG "source" , dotcmd }, |
11106 | #endif | 11128 | #endif |
diff --git a/shell/ash_test/ash-heredoc/heredoc_and_cmd.right b/shell/ash_test/ash-heredoc/heredoc_and_cmd.right new file mode 100644 index 000000000..25ae70561 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_and_cmd.right | |||
@@ -0,0 +1,2 @@ | |||
1 | ./heredoc_and_cmd.tests: line 4: D: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | ||
2 | Y | ||
diff --git a/shell/ash_test/ash-heredoc/heredoc_and_cmd.tests b/shell/ash_test/ash-heredoc/heredoc_and_cmd.tests new file mode 100755 index 000000000..197542de7 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_and_cmd.tests | |||
@@ -0,0 +1,8 @@ | |||
1 | # The bug was only happening with <<REDIR;CMD form below: | ||
2 | M='AAAAAAAAAAAAAAAAA' | ||
3 | fff(){ | ||
4 | date <<000; echo Y | ||
5 | ${D?$M$M$M$M$M$M} | ||
6 | 000 | ||
7 | } | ||
8 | fff | ||
diff --git a/shell/hush_test/hush-heredoc/heredoc_and_cmd.right b/shell/hush_test/hush-heredoc/heredoc_and_cmd.right new file mode 100644 index 000000000..5c19a0621 --- /dev/null +++ b/shell/hush_test/hush-heredoc/heredoc_and_cmd.right | |||
@@ -0,0 +1,2 @@ | |||
1 | hush: D: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | ||
2 | Y | ||
diff --git a/shell/hush_test/hush-heredoc/heredoc_and_cmd.tests b/shell/hush_test/hush-heredoc/heredoc_and_cmd.tests new file mode 100755 index 000000000..197542de7 --- /dev/null +++ b/shell/hush_test/hush-heredoc/heredoc_and_cmd.tests | |||
@@ -0,0 +1,8 @@ | |||
1 | # The bug was only happening with <<REDIR;CMD form below: | ||
2 | M='AAAAAAAAAAAAAAAAA' | ||
3 | fff(){ | ||
4 | date <<000; echo Y | ||
5 | ${D?$M$M$M$M$M$M} | ||
6 | 000 | ||
7 | } | ||
8 | fff | ||