diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-03 19:54:42 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-03 19:54:42 +0200 |
| commit | 05f2bedaebd694605abd1f199fc25d93ad73840b (patch) | |
| tree | a025f39e5cc6f548d3240a7a3fcd91a7752a15ff /coreutils | |
| parent | ff8fde111e11e973b269467dd86f235a27f653df (diff) | |
| download | busybox-w32-05f2bedaebd694605abd1f199fc25d93ad73840b.tar.gz busybox-w32-05f2bedaebd694605abd1f199fc25d93ad73840b.tar.bz2 busybox-w32-05f2bedaebd694605abd1f199fc25d93ad73840b.zip | |
ash: sleep builtin with no arguments should not exit
function old new delta
sleep_main 116 143 +27
.rodata 105245 105268 +23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 50/0) Total: 50 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/sleep.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 442841210..667db558d 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c | |||
| @@ -65,15 +65,28 @@ int sleep_main(int argc UNUSED_PARAM, char **argv) | |||
| 65 | { | 65 | { |
| 66 | duration_t duration; | 66 | duration_t duration; |
| 67 | 67 | ||
| 68 | /* Note: sleep_main may be directly called from ash as a builtin. | ||
| 69 | * This brings some complications: | ||
| 70 | * + we can't use xfunc here | ||
| 71 | * + we can't use bb_show_usage | ||
| 72 | * + applet_name can be the name of the shell | ||
| 73 | */ | ||
| 68 | ++argv; | 74 | ++argv; |
| 69 | if (!*argv) | 75 | if (!*argv) { |
| 76 | /* Without this, bare "sleep" in ash shows _ash_ --help */ | ||
| 77 | if (ENABLE_ASH_SLEEP && applet_name[0] != 's') { | ||
| 78 | bb_simple_error_msg("sleep: missing operand"); | ||
| 79 | return EXIT_FAILURE; | ||
| 80 | } | ||
| 70 | bb_show_usage(); | 81 | bb_show_usage(); |
| 82 | } | ||
| 71 | 83 | ||
| 72 | /* GNU sleep accepts "inf", "INF", "infinity" and "INFINITY" */ | 84 | /* GNU sleep accepts "inf", "INF", "infinity" and "INFINITY" */ |
| 73 | if (strncasecmp(argv[0], "inf", 3) == 0) | 85 | if (strncasecmp(argv[0], "inf", 3) == 0) |
| 74 | for (;;) | 86 | for (;;) |
| 75 | sleep(INT_MAX); | 87 | sleep(INT_MAX); |
| 76 | 88 | ||
| 89 | //FIXME: in ash, "sleep 123qwerty" as a builtin aborts the shell | ||
| 77 | #if ENABLE_FEATURE_FANCY_SLEEP | 90 | #if ENABLE_FEATURE_FANCY_SLEEP |
| 78 | duration = 0; | 91 | duration = 0; |
| 79 | do { | 92 | do { |
