sleep: support "inf"
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 7 Jan 2019 14:20:56 +0000 (15:20 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 7 Jan 2019 14:20:56 +0000 (15:20 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/sleep.c
miscutils/bc.c

index 5c9cda9f0087d89d221b284c8f003cd5798a8435..7bfaab9202264cdcf190324f099a7a9d27ce6129 100644 (file)
@@ -68,6 +68,11 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
        if (!*argv)
                bb_show_usage();
 
+       /* GNU sleep accepts "inf", "INF", "infinity" and "INFINITY" */
+       if (strncasecmp(argv[0], "inf", 3) == 0)
+               for (;;)
+                       sleep(INT_MAX);
+
 #if ENABLE_FEATURE_FANCY_SLEEP
 # if ENABLE_FLOAT_DURATION
        /* undo busybox.c setlocale */
index 74884557ad5035d62f122f3866c5e88d03eb67e8..bf174dafb07526de33df87af8d66f6cbee90b72d 100644 (file)
@@ -7407,4 +7407,3 @@ int dc_main(int argc UNUSED_PARAM, char **argv)
 #endif
 
 #endif // DC_BIG
-