diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 26 |
1 files changed, 24 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 |